deeprails 1.6.1__tar.gz → 1.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of deeprails might be problematic. Click here for more details.
- deeprails-1.8.0/.release-please-manifest.json +3 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/CHANGELOG.md +16 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/PKG-INFO +25 -25
- {deeprails-1.6.1 → deeprails-1.8.0}/README.md +24 -24
- {deeprails-1.6.1 → deeprails-1.8.0}/pyproject.toml +1 -1
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_version.py +1 -1
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/resources/defend.py +45 -45
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/resources/evaluate.py +4 -4
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/resources/monitor.py +4 -4
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/defend_create_workflow_params.py +19 -19
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/defend_response.py +8 -8
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/defend_submit_event_params.py +2 -2
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/evaluate_create_params.py +2 -2
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/evaluation.py +2 -2
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/monitor_submit_event_params.py +2 -2
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/api_resources/test_defend.py +18 -20
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/test_client.py +10 -26
- deeprails-1.6.1/.release-please-manifest.json +0 -3
- {deeprails-1.6.1 → deeprails-1.8.0}/.gitignore +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/CONTRIBUTING.md +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/LICENSE +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/api.md +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/bin/check-release-environment +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/bin/publish-pypi +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/examples/.keep +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/noxfile.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/release-please-config.json +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/requirements-dev.lock +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/requirements.lock +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/__init__.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_base_client.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_client.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_compat.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_constants.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_exceptions.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_files.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_models.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_qs.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_resource.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_response.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_streaming.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_types.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_utils/__init__.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_utils/_compat.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_utils/_datetime_parse.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_utils/_logs.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_utils/_proxy.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_utils/_reflection.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_utils/_resources_proxy.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_utils/_streams.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_utils/_sync.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_utils/_transform.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_utils/_typing.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/_utils/_utils.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/lib/.keep +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/py.typed +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/resources/__init__.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/__init__.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/api_response.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/defend_update_workflow_params.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/monitor_create_params.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/monitor_retrieve_params.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/monitor_retrieve_response.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/monitor_submit_event_response.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/monitor_update_params.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/src/deeprails/types/workflow_event_response.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/__init__.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/api_resources/__init__.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/api_resources/test_evaluate.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/api_resources/test_monitor.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/conftest.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/sample_file.txt +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/test_deepcopy.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/test_extract_files.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/test_files.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/test_models.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/test_qs.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/test_required_args.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/test_response.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/test_streaming.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/test_transform.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/test_utils/test_datetime_parse.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/test_utils/test_proxy.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/test_utils/test_typing.py +0 -0
- {deeprails-1.6.1 → deeprails-1.8.0}/tests/utils.py +0 -0
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.8.0 (2025-10-22)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v1.7.0...v1.8.0](https://github.com/deeprails/deeprails-sdk-python/compare/v1.7.0...v1.8.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** manual updates ([4b46121](https://github.com/deeprails/deeprails-sdk-python/commit/4b461213615578ca0382f044201c8343d4e9f167))
|
|
10
|
+
|
|
11
|
+
## 1.7.0 (2025-10-22)
|
|
12
|
+
|
|
13
|
+
Full Changelog: [v1.6.1...v1.7.0](https://github.com/deeprails/deeprails-sdk-python/compare/v1.6.1...v1.7.0)
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **api:** update defend naming and data structures ([ba934de](https://github.com/deeprails/deeprails-sdk-python/commit/ba934de8812d71da159a00fa8283876e682aeb7b))
|
|
18
|
+
|
|
3
19
|
## 1.6.1 (2025-10-22)
|
|
4
20
|
|
|
5
21
|
Full Changelog: [v1.6.0...v1.6.1](https://github.com/deeprails/deeprails-sdk-python/compare/v1.6.0...v1.6.1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: deeprails
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.8.0
|
|
4
4
|
Summary: The official Python library for the deeprails API
|
|
5
5
|
Project-URL: Homepage, https://docs.deeprails.com/
|
|
6
6
|
Project-URL: Repository, https://github.com/deeprails/deeprails-sdk-python
|
|
@@ -67,12 +67,12 @@ client = Deeprails(
|
|
|
67
67
|
|
|
68
68
|
defend_response = client.defend.create_workflow(
|
|
69
69
|
improvement_action="fixit",
|
|
70
|
-
|
|
70
|
+
name="Push Alert Workflow",
|
|
71
|
+
type="custom",
|
|
72
|
+
custom_hallucination_threshold_values={
|
|
71
73
|
"completeness": 0.7,
|
|
72
74
|
"instruction_adherence": 0.75,
|
|
73
75
|
},
|
|
74
|
-
name="Push Alert Workflow",
|
|
75
|
-
type="custom",
|
|
76
76
|
)
|
|
77
77
|
print(defend_response.workflow_id)
|
|
78
78
|
```
|
|
@@ -99,12 +99,12 @@ client = AsyncDeeprails(
|
|
|
99
99
|
async def main() -> None:
|
|
100
100
|
defend_response = await client.defend.create_workflow(
|
|
101
101
|
improvement_action="fixit",
|
|
102
|
-
|
|
102
|
+
name="Push Alert Workflow",
|
|
103
|
+
type="custom",
|
|
104
|
+
custom_hallucination_threshold_values={
|
|
103
105
|
"completeness": 0.7,
|
|
104
106
|
"instruction_adherence": 0.75,
|
|
105
107
|
},
|
|
106
|
-
name="Push Alert Workflow",
|
|
107
|
-
type="custom",
|
|
108
108
|
)
|
|
109
109
|
print(defend_response.workflow_id)
|
|
110
110
|
|
|
@@ -140,12 +140,12 @@ async def main() -> None:
|
|
|
140
140
|
) as client:
|
|
141
141
|
defend_response = await client.defend.create_workflow(
|
|
142
142
|
improvement_action="fixit",
|
|
143
|
-
|
|
143
|
+
name="Push Alert Workflow",
|
|
144
|
+
type="custom",
|
|
145
|
+
custom_hallucination_threshold_values={
|
|
144
146
|
"completeness": 0.7,
|
|
145
147
|
"instruction_adherence": 0.75,
|
|
146
148
|
},
|
|
147
|
-
name="Push Alert Workflow",
|
|
148
|
-
type="custom",
|
|
149
149
|
)
|
|
150
150
|
print(defend_response.workflow_id)
|
|
151
151
|
|
|
@@ -199,12 +199,12 @@ client = Deeprails()
|
|
|
199
199
|
try:
|
|
200
200
|
client.defend.create_workflow(
|
|
201
201
|
improvement_action="fixit",
|
|
202
|
-
|
|
202
|
+
name="Push Alert Workflow",
|
|
203
|
+
type="custom",
|
|
204
|
+
custom_hallucination_threshold_values={
|
|
203
205
|
"completeness": 0.7,
|
|
204
206
|
"instruction_adherence": 0.75,
|
|
205
207
|
},
|
|
206
|
-
name="Push Alert Workflow",
|
|
207
|
-
type="custom",
|
|
208
208
|
)
|
|
209
209
|
except deeprails.APIConnectionError as e:
|
|
210
210
|
print("The server could not be reached")
|
|
@@ -250,12 +250,12 @@ client = Deeprails(
|
|
|
250
250
|
# Or, configure per-request:
|
|
251
251
|
client.with_options(max_retries=5).defend.create_workflow(
|
|
252
252
|
improvement_action="fixit",
|
|
253
|
-
|
|
253
|
+
name="Push Alert Workflow",
|
|
254
|
+
type="custom",
|
|
255
|
+
custom_hallucination_threshold_values={
|
|
254
256
|
"completeness": 0.7,
|
|
255
257
|
"instruction_adherence": 0.75,
|
|
256
258
|
},
|
|
257
|
-
name="Push Alert Workflow",
|
|
258
|
-
type="custom",
|
|
259
259
|
)
|
|
260
260
|
```
|
|
261
261
|
|
|
@@ -281,12 +281,12 @@ client = Deeprails(
|
|
|
281
281
|
# Override per-request:
|
|
282
282
|
client.with_options(timeout=5.0).defend.create_workflow(
|
|
283
283
|
improvement_action="fixit",
|
|
284
|
-
|
|
284
|
+
name="Push Alert Workflow",
|
|
285
|
+
type="custom",
|
|
286
|
+
custom_hallucination_threshold_values={
|
|
285
287
|
"completeness": 0.7,
|
|
286
288
|
"instruction_adherence": 0.75,
|
|
287
289
|
},
|
|
288
|
-
name="Push Alert Workflow",
|
|
289
|
-
type="custom",
|
|
290
290
|
)
|
|
291
291
|
```
|
|
292
292
|
|
|
@@ -330,12 +330,12 @@ from deeprails import Deeprails
|
|
|
330
330
|
client = Deeprails()
|
|
331
331
|
response = client.defend.with_raw_response.create_workflow(
|
|
332
332
|
improvement_action="fixit",
|
|
333
|
-
|
|
333
|
+
name="Push Alert Workflow",
|
|
334
|
+
type="custom",
|
|
335
|
+
custom_hallucination_threshold_values={
|
|
334
336
|
"completeness": 0.7,
|
|
335
337
|
"instruction_adherence": 0.75,
|
|
336
338
|
},
|
|
337
|
-
name="Push Alert Workflow",
|
|
338
|
-
type="custom",
|
|
339
339
|
)
|
|
340
340
|
print(response.headers.get('X-My-Header'))
|
|
341
341
|
|
|
@@ -356,12 +356,12 @@ To stream the response body, use `.with_streaming_response` instead, which requi
|
|
|
356
356
|
```python
|
|
357
357
|
with client.defend.with_streaming_response.create_workflow(
|
|
358
358
|
improvement_action="fixit",
|
|
359
|
-
|
|
359
|
+
name="Push Alert Workflow",
|
|
360
|
+
type="custom",
|
|
361
|
+
custom_hallucination_threshold_values={
|
|
360
362
|
"completeness": 0.7,
|
|
361
363
|
"instruction_adherence": 0.75,
|
|
362
364
|
},
|
|
363
|
-
name="Push Alert Workflow",
|
|
364
|
-
type="custom",
|
|
365
365
|
) as response:
|
|
366
366
|
print(response.headers.get("X-My-Header"))
|
|
367
367
|
|
|
@@ -32,12 +32,12 @@ client = Deeprails(
|
|
|
32
32
|
|
|
33
33
|
defend_response = client.defend.create_workflow(
|
|
34
34
|
improvement_action="fixit",
|
|
35
|
-
|
|
35
|
+
name="Push Alert Workflow",
|
|
36
|
+
type="custom",
|
|
37
|
+
custom_hallucination_threshold_values={
|
|
36
38
|
"completeness": 0.7,
|
|
37
39
|
"instruction_adherence": 0.75,
|
|
38
40
|
},
|
|
39
|
-
name="Push Alert Workflow",
|
|
40
|
-
type="custom",
|
|
41
41
|
)
|
|
42
42
|
print(defend_response.workflow_id)
|
|
43
43
|
```
|
|
@@ -64,12 +64,12 @@ client = AsyncDeeprails(
|
|
|
64
64
|
async def main() -> None:
|
|
65
65
|
defend_response = await client.defend.create_workflow(
|
|
66
66
|
improvement_action="fixit",
|
|
67
|
-
|
|
67
|
+
name="Push Alert Workflow",
|
|
68
|
+
type="custom",
|
|
69
|
+
custom_hallucination_threshold_values={
|
|
68
70
|
"completeness": 0.7,
|
|
69
71
|
"instruction_adherence": 0.75,
|
|
70
72
|
},
|
|
71
|
-
name="Push Alert Workflow",
|
|
72
|
-
type="custom",
|
|
73
73
|
)
|
|
74
74
|
print(defend_response.workflow_id)
|
|
75
75
|
|
|
@@ -105,12 +105,12 @@ async def main() -> None:
|
|
|
105
105
|
) as client:
|
|
106
106
|
defend_response = await client.defend.create_workflow(
|
|
107
107
|
improvement_action="fixit",
|
|
108
|
-
|
|
108
|
+
name="Push Alert Workflow",
|
|
109
|
+
type="custom",
|
|
110
|
+
custom_hallucination_threshold_values={
|
|
109
111
|
"completeness": 0.7,
|
|
110
112
|
"instruction_adherence": 0.75,
|
|
111
113
|
},
|
|
112
|
-
name="Push Alert Workflow",
|
|
113
|
-
type="custom",
|
|
114
114
|
)
|
|
115
115
|
print(defend_response.workflow_id)
|
|
116
116
|
|
|
@@ -164,12 +164,12 @@ client = Deeprails()
|
|
|
164
164
|
try:
|
|
165
165
|
client.defend.create_workflow(
|
|
166
166
|
improvement_action="fixit",
|
|
167
|
-
|
|
167
|
+
name="Push Alert Workflow",
|
|
168
|
+
type="custom",
|
|
169
|
+
custom_hallucination_threshold_values={
|
|
168
170
|
"completeness": 0.7,
|
|
169
171
|
"instruction_adherence": 0.75,
|
|
170
172
|
},
|
|
171
|
-
name="Push Alert Workflow",
|
|
172
|
-
type="custom",
|
|
173
173
|
)
|
|
174
174
|
except deeprails.APIConnectionError as e:
|
|
175
175
|
print("The server could not be reached")
|
|
@@ -215,12 +215,12 @@ client = Deeprails(
|
|
|
215
215
|
# Or, configure per-request:
|
|
216
216
|
client.with_options(max_retries=5).defend.create_workflow(
|
|
217
217
|
improvement_action="fixit",
|
|
218
|
-
|
|
218
|
+
name="Push Alert Workflow",
|
|
219
|
+
type="custom",
|
|
220
|
+
custom_hallucination_threshold_values={
|
|
219
221
|
"completeness": 0.7,
|
|
220
222
|
"instruction_adherence": 0.75,
|
|
221
223
|
},
|
|
222
|
-
name="Push Alert Workflow",
|
|
223
|
-
type="custom",
|
|
224
224
|
)
|
|
225
225
|
```
|
|
226
226
|
|
|
@@ -246,12 +246,12 @@ client = Deeprails(
|
|
|
246
246
|
# Override per-request:
|
|
247
247
|
client.with_options(timeout=5.0).defend.create_workflow(
|
|
248
248
|
improvement_action="fixit",
|
|
249
|
-
|
|
249
|
+
name="Push Alert Workflow",
|
|
250
|
+
type="custom",
|
|
251
|
+
custom_hallucination_threshold_values={
|
|
250
252
|
"completeness": 0.7,
|
|
251
253
|
"instruction_adherence": 0.75,
|
|
252
254
|
},
|
|
253
|
-
name="Push Alert Workflow",
|
|
254
|
-
type="custom",
|
|
255
255
|
)
|
|
256
256
|
```
|
|
257
257
|
|
|
@@ -295,12 +295,12 @@ from deeprails import Deeprails
|
|
|
295
295
|
client = Deeprails()
|
|
296
296
|
response = client.defend.with_raw_response.create_workflow(
|
|
297
297
|
improvement_action="fixit",
|
|
298
|
-
|
|
298
|
+
name="Push Alert Workflow",
|
|
299
|
+
type="custom",
|
|
300
|
+
custom_hallucination_threshold_values={
|
|
299
301
|
"completeness": 0.7,
|
|
300
302
|
"instruction_adherence": 0.75,
|
|
301
303
|
},
|
|
302
|
-
name="Push Alert Workflow",
|
|
303
|
-
type="custom",
|
|
304
304
|
)
|
|
305
305
|
print(response.headers.get('X-My-Header'))
|
|
306
306
|
|
|
@@ -321,12 +321,12 @@ To stream the response body, use `.with_streaming_response` instead, which requi
|
|
|
321
321
|
```python
|
|
322
322
|
with client.defend.with_streaming_response.create_workflow(
|
|
323
323
|
improvement_action="fixit",
|
|
324
|
-
|
|
324
|
+
name="Push Alert Workflow",
|
|
325
|
+
type="custom",
|
|
326
|
+
custom_hallucination_threshold_values={
|
|
325
327
|
"completeness": 0.7,
|
|
326
328
|
"instruction_adherence": 0.75,
|
|
327
329
|
},
|
|
328
|
-
name="Push Alert Workflow",
|
|
329
|
-
type="custom",
|
|
330
330
|
) as response:
|
|
331
331
|
print(response.headers.get("X-My-Header"))
|
|
332
332
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import Dict
|
|
5
|
+
from typing import Dict
|
|
6
6
|
from typing_extensions import Literal
|
|
7
7
|
|
|
8
8
|
import httpx
|
|
@@ -48,13 +48,13 @@ class DefendResource(SyncAPIResource):
|
|
|
48
48
|
def create_workflow(
|
|
49
49
|
self,
|
|
50
50
|
*,
|
|
51
|
-
improvement_action:
|
|
52
|
-
metrics: Dict[str, float],
|
|
51
|
+
improvement_action: Literal["regen", "fixit", "do_nothing"],
|
|
53
52
|
name: str,
|
|
54
53
|
type: Literal["automatic", "custom"],
|
|
55
|
-
|
|
54
|
+
automatic_hallucination_tolerance_levels: Dict[str, Literal["low", "medium", "high"]] | Omit = omit,
|
|
55
|
+
custom_hallucination_threshold_values: Dict[str, float] | Omit = omit,
|
|
56
56
|
description: str | Omit = omit,
|
|
57
|
-
|
|
57
|
+
max_improvement_attempt: int | Omit = omit,
|
|
58
58
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
59
59
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
60
60
|
extra_headers: Headers | None = None,
|
|
@@ -68,16 +68,10 @@ class DefendResource(SyncAPIResource):
|
|
|
68
68
|
|
|
69
69
|
Args:
|
|
70
70
|
improvement_action: The action used to improve outputs that fail one or guardrail metrics for the
|
|
71
|
-
workflow events. May be `
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
metrics: Mapping of guardrail metrics to floating point threshold values. If the workflow
|
|
77
|
-
type is automatic, only the metric names are used (`automatic_tolerance`
|
|
78
|
-
determines thresholds). Possible metrics are `correctness`, `completeness`,
|
|
79
|
-
`instruction_adherence`, `context_adherence`, `ground_truth_adherence`, or
|
|
80
|
-
`comprehensive_safety`.
|
|
71
|
+
workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs the user's
|
|
72
|
+
input prompt with minor induced variance. FixIt attempts to directly address the
|
|
73
|
+
shortcomings of the output using the guardrail failure rationale. Do Nothing
|
|
74
|
+
does not attempt any improvement.
|
|
81
75
|
|
|
82
76
|
name: Name of the workflow.
|
|
83
77
|
|
|
@@ -87,12 +81,18 @@ class DefendResource(SyncAPIResource):
|
|
|
87
81
|
set the threshold for each metric as a floating point number between 0.0 and
|
|
88
82
|
1.0.
|
|
89
83
|
|
|
90
|
-
|
|
91
|
-
`
|
|
84
|
+
automatic_hallucination_tolerance_levels: Mapping of guardrail metrics to hallucination tolerance levels (either `low`,
|
|
85
|
+
`medium`, or `high`). Possible metrics are `completeness`,
|
|
86
|
+
`instruction_adherence`, `context_adherence`, `ground_truth_adherence`, or
|
|
87
|
+
`comprehensive_safety`.
|
|
88
|
+
|
|
89
|
+
custom_hallucination_threshold_values: Mapping of guardrail metrics to floating point threshold values. Possible
|
|
90
|
+
metrics are `correctness`, `completeness`, `instruction_adherence`,
|
|
91
|
+
`context_adherence`, `ground_truth_adherence`, or `comprehensive_safety`.
|
|
92
92
|
|
|
93
93
|
description: Description for the workflow.
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
max_improvement_attempt: Max. number of improvement action retries until a given event passes the
|
|
96
96
|
guardrails. Defaults to 10.
|
|
97
97
|
|
|
98
98
|
extra_headers: Send extra headers
|
|
@@ -108,12 +108,12 @@ class DefendResource(SyncAPIResource):
|
|
|
108
108
|
body=maybe_transform(
|
|
109
109
|
{
|
|
110
110
|
"improvement_action": improvement_action,
|
|
111
|
-
"metrics": metrics,
|
|
112
111
|
"name": name,
|
|
113
112
|
"type": type,
|
|
114
|
-
"
|
|
113
|
+
"automatic_hallucination_tolerance_levels": automatic_hallucination_tolerance_levels,
|
|
114
|
+
"custom_hallucination_threshold_values": custom_hallucination_threshold_values,
|
|
115
115
|
"description": description,
|
|
116
|
-
"
|
|
116
|
+
"max_improvement_attempt": max_improvement_attempt,
|
|
117
117
|
},
|
|
118
118
|
defend_create_workflow_params.DefendCreateWorkflowParams,
|
|
119
119
|
),
|
|
@@ -214,8 +214,8 @@ class DefendResource(SyncAPIResource):
|
|
|
214
214
|
|
|
215
215
|
Args:
|
|
216
216
|
model_input: A dictionary of inputs sent to the LLM to generate output. The dictionary must
|
|
217
|
-
contain at least
|
|
218
|
-
|
|
217
|
+
contain at least `user_prompt` or `system_prompt` field. For the
|
|
218
|
+
ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
219
219
|
|
|
220
220
|
model_output: Output generated by the LLM to be evaluated.
|
|
221
221
|
|
|
@@ -326,13 +326,13 @@ class AsyncDefendResource(AsyncAPIResource):
|
|
|
326
326
|
async def create_workflow(
|
|
327
327
|
self,
|
|
328
328
|
*,
|
|
329
|
-
improvement_action:
|
|
330
|
-
metrics: Dict[str, float],
|
|
329
|
+
improvement_action: Literal["regen", "fixit", "do_nothing"],
|
|
331
330
|
name: str,
|
|
332
331
|
type: Literal["automatic", "custom"],
|
|
333
|
-
|
|
332
|
+
automatic_hallucination_tolerance_levels: Dict[str, Literal["low", "medium", "high"]] | Omit = omit,
|
|
333
|
+
custom_hallucination_threshold_values: Dict[str, float] | Omit = omit,
|
|
334
334
|
description: str | Omit = omit,
|
|
335
|
-
|
|
335
|
+
max_improvement_attempt: int | Omit = omit,
|
|
336
336
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
337
337
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
338
338
|
extra_headers: Headers | None = None,
|
|
@@ -346,16 +346,10 @@ class AsyncDefendResource(AsyncAPIResource):
|
|
|
346
346
|
|
|
347
347
|
Args:
|
|
348
348
|
improvement_action: The action used to improve outputs that fail one or guardrail metrics for the
|
|
349
|
-
workflow events. May be `
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
metrics: Mapping of guardrail metrics to floating point threshold values. If the workflow
|
|
355
|
-
type is automatic, only the metric names are used (`automatic_tolerance`
|
|
356
|
-
determines thresholds). Possible metrics are `correctness`, `completeness`,
|
|
357
|
-
`instruction_adherence`, `context_adherence`, `ground_truth_adherence`, or
|
|
358
|
-
`comprehensive_safety`.
|
|
349
|
+
workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs the user's
|
|
350
|
+
input prompt with minor induced variance. FixIt attempts to directly address the
|
|
351
|
+
shortcomings of the output using the guardrail failure rationale. Do Nothing
|
|
352
|
+
does not attempt any improvement.
|
|
359
353
|
|
|
360
354
|
name: Name of the workflow.
|
|
361
355
|
|
|
@@ -365,12 +359,18 @@ class AsyncDefendResource(AsyncAPIResource):
|
|
|
365
359
|
set the threshold for each metric as a floating point number between 0.0 and
|
|
366
360
|
1.0.
|
|
367
361
|
|
|
368
|
-
|
|
369
|
-
`
|
|
362
|
+
automatic_hallucination_tolerance_levels: Mapping of guardrail metrics to hallucination tolerance levels (either `low`,
|
|
363
|
+
`medium`, or `high`). Possible metrics are `completeness`,
|
|
364
|
+
`instruction_adherence`, `context_adherence`, `ground_truth_adherence`, or
|
|
365
|
+
`comprehensive_safety`.
|
|
366
|
+
|
|
367
|
+
custom_hallucination_threshold_values: Mapping of guardrail metrics to floating point threshold values. Possible
|
|
368
|
+
metrics are `correctness`, `completeness`, `instruction_adherence`,
|
|
369
|
+
`context_adherence`, `ground_truth_adherence`, or `comprehensive_safety`.
|
|
370
370
|
|
|
371
371
|
description: Description for the workflow.
|
|
372
372
|
|
|
373
|
-
|
|
373
|
+
max_improvement_attempt: Max. number of improvement action retries until a given event passes the
|
|
374
374
|
guardrails. Defaults to 10.
|
|
375
375
|
|
|
376
376
|
extra_headers: Send extra headers
|
|
@@ -386,12 +386,12 @@ class AsyncDefendResource(AsyncAPIResource):
|
|
|
386
386
|
body=await async_maybe_transform(
|
|
387
387
|
{
|
|
388
388
|
"improvement_action": improvement_action,
|
|
389
|
-
"metrics": metrics,
|
|
390
389
|
"name": name,
|
|
391
390
|
"type": type,
|
|
392
|
-
"
|
|
391
|
+
"automatic_hallucination_tolerance_levels": automatic_hallucination_tolerance_levels,
|
|
392
|
+
"custom_hallucination_threshold_values": custom_hallucination_threshold_values,
|
|
393
393
|
"description": description,
|
|
394
|
-
"
|
|
394
|
+
"max_improvement_attempt": max_improvement_attempt,
|
|
395
395
|
},
|
|
396
396
|
defend_create_workflow_params.DefendCreateWorkflowParams,
|
|
397
397
|
),
|
|
@@ -492,8 +492,8 @@ class AsyncDefendResource(AsyncAPIResource):
|
|
|
492
492
|
|
|
493
493
|
Args:
|
|
494
494
|
model_input: A dictionary of inputs sent to the LLM to generate output. The dictionary must
|
|
495
|
-
contain at least
|
|
496
|
-
|
|
495
|
+
contain at least `user_prompt` or `system_prompt` field. For the
|
|
496
|
+
ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
497
497
|
|
|
498
498
|
model_output: Output generated by the LLM to be evaluated.
|
|
499
499
|
|
|
@@ -76,8 +76,8 @@ class EvaluateResource(SyncAPIResource):
|
|
|
76
76
|
|
|
77
77
|
Args:
|
|
78
78
|
model_input: A dictionary of inputs sent to the LLM to generate output. The dictionary must
|
|
79
|
-
contain at least
|
|
80
|
-
|
|
79
|
+
contain at least `user_prompt` or `system_prompt` field. For
|
|
80
|
+
ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
81
81
|
|
|
82
82
|
model_output: Output generated by the LLM to be evaluated.
|
|
83
83
|
|
|
@@ -207,8 +207,8 @@ class AsyncEvaluateResource(AsyncAPIResource):
|
|
|
207
207
|
|
|
208
208
|
Args:
|
|
209
209
|
model_input: A dictionary of inputs sent to the LLM to generate output. The dictionary must
|
|
210
|
-
contain at least
|
|
211
|
-
|
|
210
|
+
contain at least `user_prompt` or `system_prompt` field. For
|
|
211
|
+
ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
212
212
|
|
|
213
213
|
model_output: Output generated by the LLM to be evaluated.
|
|
214
214
|
|
|
@@ -220,8 +220,8 @@ class MonitorResource(SyncAPIResource):
|
|
|
220
220
|
`ground_truth_adherence`, and/or `comprehensive_safety`.
|
|
221
221
|
|
|
222
222
|
model_input: A dictionary of inputs sent to the LLM to generate output. The dictionary must
|
|
223
|
-
contain at least
|
|
224
|
-
|
|
223
|
+
contain at least a `user_prompt` or `system_prompt` field. For
|
|
224
|
+
ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
225
225
|
|
|
226
226
|
model_output: Output generated by the LLM to be evaluated.
|
|
227
227
|
|
|
@@ -458,8 +458,8 @@ class AsyncMonitorResource(AsyncAPIResource):
|
|
|
458
458
|
`ground_truth_adherence`, and/or `comprehensive_safety`.
|
|
459
459
|
|
|
460
460
|
model_input: A dictionary of inputs sent to the LLM to generate output. The dictionary must
|
|
461
|
-
contain at least
|
|
462
|
-
|
|
461
|
+
contain at least a `user_prompt` or `system_prompt` field. For
|
|
462
|
+
ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
463
463
|
|
|
464
464
|
model_output: Output generated by the LLM to be evaluated.
|
|
465
465
|
|
|
@@ -2,29 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import Dict
|
|
5
|
+
from typing import Dict
|
|
6
6
|
from typing_extensions import Literal, Required, TypedDict
|
|
7
7
|
|
|
8
8
|
__all__ = ["DefendCreateWorkflowParams"]
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class DefendCreateWorkflowParams(TypedDict, total=False):
|
|
12
|
-
improvement_action: Required[
|
|
12
|
+
improvement_action: Required[Literal["regen", "fixit", "do_nothing"]]
|
|
13
13
|
"""
|
|
14
14
|
The action used to improve outputs that fail one or guardrail metrics for the
|
|
15
|
-
workflow events. May be `
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"""
|
|
20
|
-
|
|
21
|
-
metrics: Required[Dict[str, float]]
|
|
22
|
-
"""Mapping of guardrail metrics to floating point threshold values.
|
|
23
|
-
|
|
24
|
-
If the workflow type is automatic, only the metric names are used
|
|
25
|
-
(`automatic_tolerance` determines thresholds). Possible metrics are
|
|
26
|
-
`correctness`, `completeness`, `instruction_adherence`, `context_adherence`,
|
|
27
|
-
`ground_truth_adherence`, or `comprehensive_safety`.
|
|
15
|
+
workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs the user's
|
|
16
|
+
input prompt with minor induced variance. FixIt attempts to directly address the
|
|
17
|
+
shortcomings of the output using the guardrail failure rationale. Do Nothing
|
|
18
|
+
does not attempt any improvement.
|
|
28
19
|
"""
|
|
29
20
|
|
|
30
21
|
name: Required[str]
|
|
@@ -39,16 +30,25 @@ class DefendCreateWorkflowParams(TypedDict, total=False):
|
|
|
39
30
|
1.0.
|
|
40
31
|
"""
|
|
41
32
|
|
|
42
|
-
|
|
33
|
+
automatic_hallucination_tolerance_levels: Dict[str, Literal["low", "medium", "high"]]
|
|
43
34
|
"""
|
|
44
|
-
|
|
45
|
-
`
|
|
35
|
+
Mapping of guardrail metrics to hallucination tolerance levels (either `low`,
|
|
36
|
+
`medium`, or `high`). Possible metrics are `completeness`,
|
|
37
|
+
`instruction_adherence`, `context_adherence`, `ground_truth_adherence`, or
|
|
38
|
+
`comprehensive_safety`.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
custom_hallucination_threshold_values: Dict[str, float]
|
|
42
|
+
"""Mapping of guardrail metrics to floating point threshold values.
|
|
43
|
+
|
|
44
|
+
Possible metrics are `correctness`, `completeness`, `instruction_adherence`,
|
|
45
|
+
`context_adherence`, `ground_truth_adherence`, or `comprehensive_safety`.
|
|
46
46
|
"""
|
|
47
47
|
|
|
48
48
|
description: str
|
|
49
49
|
"""Description for the workflow."""
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
max_improvement_attempt: int
|
|
52
52
|
"""Max.
|
|
53
53
|
|
|
54
54
|
number of improvement action retries until a given event passes the guardrails.
|
|
@@ -22,16 +22,16 @@ class DefendResponse(BaseModel):
|
|
|
22
22
|
description: Optional[str] = None
|
|
23
23
|
"""Description for the workflow."""
|
|
24
24
|
|
|
25
|
-
improvement_action: Optional[Literal["
|
|
25
|
+
improvement_action: Optional[Literal["regen", "fixit", "do_nothing"]] = None
|
|
26
26
|
"""
|
|
27
27
|
The action used to improve outputs that fail one or more guardrail metrics for
|
|
28
|
-
the workflow events. May be `
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
the workflow events. May be `regen`, `fixit`, or `do_nothing`. ReGen runs the
|
|
29
|
+
user's input prompt with minor induced variance. FixIt attempts to directly
|
|
30
|
+
address the shortcomings of the output using the guardrail failure rationale. Do
|
|
31
|
+
Nothing does not attempt any improvement.
|
|
32
32
|
"""
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
max_improvement_attempt: Optional[int] = None
|
|
35
35
|
"""Max.
|
|
36
36
|
|
|
37
37
|
number of improvement action retries until a given event passes the guardrails.
|
|
@@ -40,10 +40,10 @@ class DefendResponse(BaseModel):
|
|
|
40
40
|
modified_at: Optional[datetime] = None
|
|
41
41
|
"""The most recent time the workflow was modified in UTC."""
|
|
42
42
|
|
|
43
|
-
status: Optional[Literal["
|
|
43
|
+
status: Optional[Literal["inactive", "active"]] = None
|
|
44
44
|
"""Status of the selected workflow.
|
|
45
45
|
|
|
46
|
-
May be `
|
|
46
|
+
May be `inactive` or `active`. Inactive workflows will not accept events.
|
|
47
47
|
"""
|
|
48
48
|
|
|
49
49
|
success_rate: Optional[float] = None
|
|
@@ -11,8 +11,8 @@ class DefendSubmitEventParams(TypedDict, total=False):
|
|
|
11
11
|
model_input: Required[ModelInput]
|
|
12
12
|
"""A dictionary of inputs sent to the LLM to generate output.
|
|
13
13
|
|
|
14
|
-
The dictionary must contain at least
|
|
15
|
-
|
|
14
|
+
The dictionary must contain at least `user_prompt` or `system_prompt` field. For
|
|
15
|
+
the ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
model_output: Required[str]
|
|
@@ -12,8 +12,8 @@ class EvaluateCreateParams(TypedDict, total=False):
|
|
|
12
12
|
model_input: Required[ModelInput]
|
|
13
13
|
"""A dictionary of inputs sent to the LLM to generate output.
|
|
14
14
|
|
|
15
|
-
The dictionary must contain at least
|
|
16
|
-
|
|
15
|
+
The dictionary must contain at least `user_prompt` or `system_prompt` field. For
|
|
16
|
+
ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
model_output: Required[str]
|
|
@@ -32,8 +32,8 @@ class Evaluation(BaseModel):
|
|
|
32
32
|
api_model_input: ModelInput = FieldInfo(alias="model_input")
|
|
33
33
|
"""A dictionary of inputs sent to the LLM to generate output.
|
|
34
34
|
|
|
35
|
-
The dictionary must contain at least
|
|
36
|
-
|
|
35
|
+
The dictionary must contain at least `user_prompt` or `system_prompt` field. For
|
|
36
|
+
ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
37
37
|
"""
|
|
38
38
|
|
|
39
39
|
api_model_output: str = FieldInfo(alias="model_output")
|
|
@@ -31,8 +31,8 @@ class MonitorSubmitEventParams(TypedDict, total=False):
|
|
|
31
31
|
model_input: Required[ModelInput]
|
|
32
32
|
"""A dictionary of inputs sent to the LLM to generate output.
|
|
33
33
|
|
|
34
|
-
The dictionary must contain at least
|
|
35
|
-
For
|
|
34
|
+
The dictionary must contain at least a `user_prompt` or `system_prompt` field.
|
|
35
|
+
For ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
36
36
|
"""
|
|
37
37
|
|
|
38
38
|
model_output: Required[str]
|
|
@@ -24,10 +24,10 @@ class TestDefend:
|
|
|
24
24
|
@parametrize
|
|
25
25
|
def test_method_create_workflow(self, client: Deeprails) -> None:
|
|
26
26
|
defend = client.defend.create_workflow(
|
|
27
|
-
improvement_action="
|
|
28
|
-
metrics={"foo": 0},
|
|
27
|
+
improvement_action="regen",
|
|
29
28
|
name="name",
|
|
30
29
|
type="automatic",
|
|
30
|
+
automatic_hallucination_tolerance_levels={"completeness": "medium"},
|
|
31
31
|
)
|
|
32
32
|
assert_matches_type(DefendResponse, defend, path=["response"])
|
|
33
33
|
|
|
@@ -35,13 +35,12 @@ class TestDefend:
|
|
|
35
35
|
@parametrize
|
|
36
36
|
def test_method_create_workflow_with_all_params(self, client: Deeprails) -> None:
|
|
37
37
|
defend = client.defend.create_workflow(
|
|
38
|
-
improvement_action="
|
|
39
|
-
metrics={"foo": 0},
|
|
38
|
+
improvement_action="regen",
|
|
40
39
|
name="name",
|
|
41
40
|
type="automatic",
|
|
42
|
-
|
|
41
|
+
automatic_hallucination_tolerance_levels={"correctness": "low"},
|
|
43
42
|
description="description",
|
|
44
|
-
|
|
43
|
+
max_improvement_attempt=2,
|
|
45
44
|
)
|
|
46
45
|
assert_matches_type(DefendResponse, defend, path=["response"])
|
|
47
46
|
|
|
@@ -49,10 +48,10 @@ class TestDefend:
|
|
|
49
48
|
@parametrize
|
|
50
49
|
def test_raw_response_create_workflow(self, client: Deeprails) -> None:
|
|
51
50
|
response = client.defend.with_raw_response.create_workflow(
|
|
52
|
-
improvement_action="
|
|
53
|
-
metrics={"foo": 0},
|
|
51
|
+
improvement_action="regen",
|
|
54
52
|
name="name",
|
|
55
53
|
type="automatic",
|
|
54
|
+
automatic_hallucination_tolerance_levels={"completeness": "medium"},
|
|
56
55
|
)
|
|
57
56
|
|
|
58
57
|
assert response.is_closed is True
|
|
@@ -64,10 +63,10 @@ class TestDefend:
|
|
|
64
63
|
@parametrize
|
|
65
64
|
def test_streaming_response_create_workflow(self, client: Deeprails) -> None:
|
|
66
65
|
with client.defend.with_streaming_response.create_workflow(
|
|
67
|
-
improvement_action="
|
|
68
|
-
metrics={"foo": 0},
|
|
66
|
+
improvement_action="regen",
|
|
69
67
|
name="name",
|
|
70
68
|
type="automatic",
|
|
69
|
+
automatic_hallucination_tolerance_levels={"completeness": "medium"},
|
|
71
70
|
) as response:
|
|
72
71
|
assert not response.is_closed
|
|
73
72
|
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
@@ -308,10 +307,10 @@ class TestAsyncDefend:
|
|
|
308
307
|
@parametrize
|
|
309
308
|
async def test_method_create_workflow(self, async_client: AsyncDeeprails) -> None:
|
|
310
309
|
defend = await async_client.defend.create_workflow(
|
|
311
|
-
improvement_action="
|
|
312
|
-
metrics={"foo": 0},
|
|
310
|
+
improvement_action="regen",
|
|
313
311
|
name="name",
|
|
314
312
|
type="automatic",
|
|
313
|
+
automatic_hallucination_tolerance_levels={"completeness": "medium"},
|
|
315
314
|
)
|
|
316
315
|
assert_matches_type(DefendResponse, defend, path=["response"])
|
|
317
316
|
|
|
@@ -319,13 +318,12 @@ class TestAsyncDefend:
|
|
|
319
318
|
@parametrize
|
|
320
319
|
async def test_method_create_workflow_with_all_params(self, async_client: AsyncDeeprails) -> None:
|
|
321
320
|
defend = await async_client.defend.create_workflow(
|
|
322
|
-
improvement_action="
|
|
323
|
-
metrics={"foo": 0},
|
|
321
|
+
improvement_action="regen",
|
|
324
322
|
name="name",
|
|
325
323
|
type="automatic",
|
|
326
|
-
|
|
324
|
+
automatic_hallucination_tolerance_levels={"correctness": "low"},
|
|
327
325
|
description="description",
|
|
328
|
-
|
|
326
|
+
max_improvement_attempt=2,
|
|
329
327
|
)
|
|
330
328
|
assert_matches_type(DefendResponse, defend, path=["response"])
|
|
331
329
|
|
|
@@ -333,10 +331,10 @@ class TestAsyncDefend:
|
|
|
333
331
|
@parametrize
|
|
334
332
|
async def test_raw_response_create_workflow(self, async_client: AsyncDeeprails) -> None:
|
|
335
333
|
response = await async_client.defend.with_raw_response.create_workflow(
|
|
336
|
-
improvement_action="
|
|
337
|
-
metrics={"foo": 0},
|
|
334
|
+
improvement_action="regen",
|
|
338
335
|
name="name",
|
|
339
336
|
type="automatic",
|
|
337
|
+
automatic_hallucination_tolerance_levels={"completeness": "medium"},
|
|
340
338
|
)
|
|
341
339
|
|
|
342
340
|
assert response.is_closed is True
|
|
@@ -348,10 +346,10 @@ class TestAsyncDefend:
|
|
|
348
346
|
@parametrize
|
|
349
347
|
async def test_streaming_response_create_workflow(self, async_client: AsyncDeeprails) -> None:
|
|
350
348
|
async with async_client.defend.with_streaming_response.create_workflow(
|
|
351
|
-
improvement_action="
|
|
352
|
-
metrics={"foo": 0},
|
|
349
|
+
improvement_action="regen",
|
|
353
350
|
name="name",
|
|
354
351
|
type="automatic",
|
|
352
|
+
automatic_hallucination_tolerance_levels={"completeness": "medium"},
|
|
355
353
|
) as response:
|
|
356
354
|
assert not response.is_closed
|
|
357
355
|
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
|
|
@@ -718,7 +718,7 @@ class TestDeeprails:
|
|
|
718
718
|
|
|
719
719
|
with pytest.raises(APITimeoutError):
|
|
720
720
|
client.defend.with_streaming_response.create_workflow(
|
|
721
|
-
improvement_action="
|
|
721
|
+
improvement_action="regen", name="name", type="automatic", automatic_hallucination_tolerance_levels={"correctness": "medium"}
|
|
722
722
|
).__enter__()
|
|
723
723
|
|
|
724
724
|
assert _get_open_connections(self.client) == 0
|
|
@@ -730,7 +730,7 @@ class TestDeeprails:
|
|
|
730
730
|
|
|
731
731
|
with pytest.raises(APIStatusError):
|
|
732
732
|
client.defend.with_streaming_response.create_workflow(
|
|
733
|
-
improvement_action="
|
|
733
|
+
improvement_action="regen", name="name", type="automatic", automatic_hallucination_tolerance_levels={"correctness": "medium"}
|
|
734
734
|
).__enter__()
|
|
735
735
|
assert _get_open_connections(self.client) == 0
|
|
736
736
|
|
|
@@ -761,7 +761,7 @@ class TestDeeprails:
|
|
|
761
761
|
respx_mock.post("/defend").mock(side_effect=retry_handler)
|
|
762
762
|
|
|
763
763
|
response = client.defend.with_raw_response.create_workflow(
|
|
764
|
-
improvement_action="
|
|
764
|
+
improvement_action="regen", name="name", type="automatic", automatic_hallucination_tolerance_levels={"correctness": "medium"}
|
|
765
765
|
)
|
|
766
766
|
|
|
767
767
|
assert response.retries_taken == failures_before_success
|
|
@@ -787,11 +787,7 @@ class TestDeeprails:
|
|
|
787
787
|
respx_mock.post("/defend").mock(side_effect=retry_handler)
|
|
788
788
|
|
|
789
789
|
response = client.defend.with_raw_response.create_workflow(
|
|
790
|
-
improvement_action="
|
|
791
|
-
metrics={"foo": 0},
|
|
792
|
-
name="name",
|
|
793
|
-
type="automatic",
|
|
794
|
-
extra_headers={"x-stainless-retry-count": Omit()},
|
|
790
|
+
improvement_action="regen", name="name", type="automatic", automatic_hallucination_tolerance_levels={"correctness": "medium"}, extra_headers={"x-stainless-retry-count": Omit()}
|
|
795
791
|
)
|
|
796
792
|
|
|
797
793
|
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
|
|
@@ -816,11 +812,7 @@ class TestDeeprails:
|
|
|
816
812
|
respx_mock.post("/defend").mock(side_effect=retry_handler)
|
|
817
813
|
|
|
818
814
|
response = client.defend.with_raw_response.create_workflow(
|
|
819
|
-
improvement_action="
|
|
820
|
-
metrics={"foo": 0},
|
|
821
|
-
name="name",
|
|
822
|
-
type="automatic",
|
|
823
|
-
extra_headers={"x-stainless-retry-count": "42"},
|
|
815
|
+
improvement_action="regen", name="name", type="automatic", automatic_hallucination_tolerance_levels={"correctness": "medium"}, extra_headers={"x-stainless-retry-count": "42"}
|
|
824
816
|
)
|
|
825
817
|
|
|
826
818
|
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
|
|
@@ -1553,7 +1545,7 @@ class TestAsyncDeeprails:
|
|
|
1553
1545
|
|
|
1554
1546
|
with pytest.raises(APITimeoutError):
|
|
1555
1547
|
await async_client.defend.with_streaming_response.create_workflow(
|
|
1556
|
-
improvement_action="
|
|
1548
|
+
improvement_action="regen", name="name", type="automatic", automatic_hallucination_tolerance_levels={"correctness": "medium"}
|
|
1557
1549
|
).__aenter__()
|
|
1558
1550
|
|
|
1559
1551
|
assert _get_open_connections(self.client) == 0
|
|
@@ -1567,7 +1559,7 @@ class TestAsyncDeeprails:
|
|
|
1567
1559
|
|
|
1568
1560
|
with pytest.raises(APIStatusError):
|
|
1569
1561
|
await async_client.defend.with_streaming_response.create_workflow(
|
|
1570
|
-
improvement_action="
|
|
1562
|
+
improvement_action="regen", name="name", type="automatic", automatic_hallucination_tolerance_levels={"correctness": "medium"}
|
|
1571
1563
|
).__aenter__()
|
|
1572
1564
|
assert _get_open_connections(self.client) == 0
|
|
1573
1565
|
|
|
@@ -1599,7 +1591,7 @@ class TestAsyncDeeprails:
|
|
|
1599
1591
|
respx_mock.post("/defend").mock(side_effect=retry_handler)
|
|
1600
1592
|
|
|
1601
1593
|
response = await client.defend.with_raw_response.create_workflow(
|
|
1602
|
-
improvement_action="
|
|
1594
|
+
improvement_action="regen", name="name", type="automatic", automatic_hallucination_tolerance_levels={"correctness": "medium"}
|
|
1603
1595
|
)
|
|
1604
1596
|
|
|
1605
1597
|
assert response.retries_taken == failures_before_success
|
|
@@ -1626,11 +1618,7 @@ class TestAsyncDeeprails:
|
|
|
1626
1618
|
respx_mock.post("/defend").mock(side_effect=retry_handler)
|
|
1627
1619
|
|
|
1628
1620
|
response = await client.defend.with_raw_response.create_workflow(
|
|
1629
|
-
improvement_action="
|
|
1630
|
-
metrics={"foo": 0},
|
|
1631
|
-
name="name",
|
|
1632
|
-
type="automatic",
|
|
1633
|
-
extra_headers={"x-stainless-retry-count": Omit()},
|
|
1621
|
+
improvement_action="regen", name="name", type="automatic", automatic_hallucination_tolerance_levels={"correctness": "medium"}, extra_headers={"x-stainless-retry-count": Omit()}
|
|
1634
1622
|
)
|
|
1635
1623
|
|
|
1636
1624
|
assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0
|
|
@@ -1656,11 +1644,7 @@ class TestAsyncDeeprails:
|
|
|
1656
1644
|
respx_mock.post("/defend").mock(side_effect=retry_handler)
|
|
1657
1645
|
|
|
1658
1646
|
response = await client.defend.with_raw_response.create_workflow(
|
|
1659
|
-
improvement_action="
|
|
1660
|
-
metrics={"foo": 0},
|
|
1661
|
-
name="name",
|
|
1662
|
-
type="automatic",
|
|
1663
|
-
extra_headers={"x-stainless-retry-count": "42"},
|
|
1647
|
+
improvement_action="regen", name="name", type="automatic", automatic_hallucination_tolerance_levels={"correctness": "medium"}, extra_headers={"x-stainless-retry-count": "42"}
|
|
1664
1648
|
)
|
|
1665
1649
|
|
|
1666
1650
|
assert response.http_request.headers.get("x-stainless-retry-count") == "42"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|