deeprails 1.11.0__tar.gz → 1.12.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.
- deeprails-1.12.0/.release-please-manifest.json +3 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/CHANGELOG.md +13 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/PKG-INFO +1 -1
- {deeprails-1.11.0 → deeprails-1.12.0}/pyproject.toml +1 -1
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_version.py +1 -1
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/resources/monitor.py +51 -41
- deeprails-1.12.0/src/deeprails/types/monitor_create_params.py +46 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/monitor_submit_event_params.py +0 -23
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/api_resources/test_monitor.py +12 -12
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/test_client.py +198 -164
- deeprails-1.11.0/.release-please-manifest.json +0 -3
- deeprails-1.11.0/src/deeprails/types/monitor_create_params.py +0 -15
- {deeprails-1.11.0 → deeprails-1.12.0}/.gitignore +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/CONTRIBUTING.md +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/LICENSE +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/README.md +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/api.md +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/bin/check-release-environment +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/bin/publish-pypi +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/examples/.keep +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/noxfile.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/release-please-config.json +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/requirements-dev.lock +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/requirements.lock +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/__init__.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_base_client.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_client.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_compat.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_constants.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_exceptions.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_files.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_models.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_qs.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_resource.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_response.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_streaming.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_types.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_utils/__init__.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_utils/_compat.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_utils/_datetime_parse.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_utils/_logs.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_utils/_proxy.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_utils/_reflection.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_utils/_resources_proxy.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_utils/_streams.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_utils/_sync.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_utils/_transform.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_utils/_typing.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/_utils/_utils.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/lib/.keep +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/py.typed +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/resources/__init__.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/resources/defend.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/resources/files.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/__init__.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/defend_create_workflow_params.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/defend_response.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/defend_submit_event_params.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/defend_update_workflow_params.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/file_response.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/file_upload_params.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/monitor_detail_response.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/monitor_event_response.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/monitor_response.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/monitor_retrieve_params.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/monitor_update_params.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/src/deeprails/types/workflow_event_response.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/__init__.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/api_resources/__init__.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/api_resources/test_defend.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/api_resources/test_files.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/conftest.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/sample_file.txt +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/test_deepcopy.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/test_extract_files.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/test_files.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/test_models.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/test_qs.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/test_required_args.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/test_response.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/test_streaming.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/test_transform.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/test_utils/test_datetime_parse.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/test_utils/test_proxy.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/test_utils/test_typing.py +0 -0
- {deeprails-1.11.0 → deeprails-1.12.0}/tests/utils.py +0 -0
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.12.0 (2025-11-02)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v1.11.0...v1.12.0](https://github.com/deeprails/deeprails-sdk-python/compare/v1.11.0...v1.12.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** restructure monitor service ([47cac0a](https://github.com/deeprails/deeprails-sdk-python/commit/47cac0a5568f3f73619ccb34e701901468dffbd0))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Chores
|
|
13
|
+
|
|
14
|
+
* **internal/tests:** avoid race condition with implicit client cleanup ([0413192](https://github.com/deeprails/deeprails-sdk-python/commit/0413192c31932a21cd34cc4fe63669914a1d1de3))
|
|
15
|
+
|
|
3
16
|
## 1.11.0 (2025-10-30)
|
|
4
17
|
|
|
5
18
|
Full Changelog: [v1.10.0...v1.11.0](https://github.com/deeprails/deeprails-sdk-python/compare/v1.10.0...v1.11.0)
|
|
@@ -8,7 +8,7 @@ from typing_extensions import Literal
|
|
|
8
8
|
import httpx
|
|
9
9
|
|
|
10
10
|
from ..types import monitor_create_params, monitor_update_params, monitor_retrieve_params, monitor_submit_event_params
|
|
11
|
-
from .._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
|
|
11
|
+
from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
|
|
12
12
|
from .._utils import maybe_transform, async_maybe_transform
|
|
13
13
|
from .._compat import cached_property
|
|
14
14
|
from .._resource import SyncAPIResource, AsyncAPIResource
|
|
@@ -49,8 +49,20 @@ class MonitorResource(SyncAPIResource):
|
|
|
49
49
|
def create(
|
|
50
50
|
self,
|
|
51
51
|
*,
|
|
52
|
+
guardrail_metrics: List[
|
|
53
|
+
Literal[
|
|
54
|
+
"correctness",
|
|
55
|
+
"completeness",
|
|
56
|
+
"instruction_adherence",
|
|
57
|
+
"context_adherence",
|
|
58
|
+
"ground_truth_adherence",
|
|
59
|
+
"comprehensive_safety",
|
|
60
|
+
]
|
|
61
|
+
],
|
|
52
62
|
name: str,
|
|
53
63
|
description: str | Omit = omit,
|
|
64
|
+
file_search: SequenceNotStr[str] | Omit = omit,
|
|
65
|
+
web_search: bool | Omit = omit,
|
|
54
66
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
55
67
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
56
68
|
extra_headers: Headers | None = None,
|
|
@@ -63,10 +75,20 @@ class MonitorResource(SyncAPIResource):
|
|
|
63
75
|
using guardrails
|
|
64
76
|
|
|
65
77
|
Args:
|
|
78
|
+
guardrail_metrics: An array of guardrail metrics that the model input and output pair will be
|
|
79
|
+
evaluated on. For non-enterprise users, these will be limited to `correctness`,
|
|
80
|
+
`completeness`, `instruction_adherence`, `context_adherence`,
|
|
81
|
+
`ground_truth_adherence`, and/or `comprehensive_safety`.
|
|
82
|
+
|
|
66
83
|
name: Name of the new monitor.
|
|
67
84
|
|
|
68
85
|
description: Description of the new monitor.
|
|
69
86
|
|
|
87
|
+
file_search: An array of file IDs to search in the monitor's evaluations. Files must be
|
|
88
|
+
uploaded via the DeepRails API first.
|
|
89
|
+
|
|
90
|
+
web_search: Whether to enable web search for this monitor's evaluations. Defaults to false.
|
|
91
|
+
|
|
70
92
|
extra_headers: Send extra headers
|
|
71
93
|
|
|
72
94
|
extra_query: Add additional query parameters to the request
|
|
@@ -79,8 +101,11 @@ class MonitorResource(SyncAPIResource):
|
|
|
79
101
|
"/monitor",
|
|
80
102
|
body=maybe_transform(
|
|
81
103
|
{
|
|
104
|
+
"guardrail_metrics": guardrail_metrics,
|
|
82
105
|
"name": name,
|
|
83
106
|
"description": description,
|
|
107
|
+
"file_search": file_search,
|
|
108
|
+
"web_search": web_search,
|
|
84
109
|
},
|
|
85
110
|
monitor_create_params.MonitorCreateParams,
|
|
86
111
|
),
|
|
@@ -187,19 +212,8 @@ class MonitorResource(SyncAPIResource):
|
|
|
187
212
|
self,
|
|
188
213
|
monitor_id: str,
|
|
189
214
|
*,
|
|
190
|
-
guardrail_metrics: List[
|
|
191
|
-
Literal[
|
|
192
|
-
"correctness",
|
|
193
|
-
"completeness",
|
|
194
|
-
"instruction_adherence",
|
|
195
|
-
"context_adherence",
|
|
196
|
-
"ground_truth_adherence",
|
|
197
|
-
"comprehensive_safety",
|
|
198
|
-
]
|
|
199
|
-
],
|
|
200
215
|
model_input: monitor_submit_event_params.ModelInput,
|
|
201
216
|
model_output: str,
|
|
202
|
-
model_used: str | Omit = omit,
|
|
203
217
|
nametag: str | Omit = omit,
|
|
204
218
|
run_mode: Literal["precision_plus", "precision", "smart", "economy"] | Omit = omit,
|
|
205
219
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
@@ -214,19 +228,12 @@ class MonitorResource(SyncAPIResource):
|
|
|
214
228
|
evaluation
|
|
215
229
|
|
|
216
230
|
Args:
|
|
217
|
-
guardrail_metrics: An array of guardrail metrics that the model input and output pair will be
|
|
218
|
-
evaluated on. For non-enterprise users, these will be limited to `correctness`,
|
|
219
|
-
`completeness`, `instruction_adherence`, `context_adherence`,
|
|
220
|
-
`ground_truth_adherence`, and/or `comprehensive_safety`.
|
|
221
|
-
|
|
222
231
|
model_input: A dictionary of inputs sent to the LLM to generate output. The dictionary must
|
|
223
232
|
contain at least a `user_prompt` field or a `system_prompt` field. For
|
|
224
233
|
ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
225
234
|
|
|
226
235
|
model_output: Output generated by the LLM to be evaluated.
|
|
227
236
|
|
|
228
|
-
model_used: Model ID used to generate the output, like `gpt-4o` or `o3`.
|
|
229
|
-
|
|
230
237
|
nametag: An optional, user-defined tag for the event.
|
|
231
238
|
|
|
232
239
|
run_mode: Run mode for the monitor event. The run mode allows the user to optimize for
|
|
@@ -248,10 +255,8 @@ class MonitorResource(SyncAPIResource):
|
|
|
248
255
|
f"/monitor/{monitor_id}/events",
|
|
249
256
|
body=maybe_transform(
|
|
250
257
|
{
|
|
251
|
-
"guardrail_metrics": guardrail_metrics,
|
|
252
258
|
"model_input": model_input,
|
|
253
259
|
"model_output": model_output,
|
|
254
|
-
"model_used": model_used,
|
|
255
260
|
"nametag": nametag,
|
|
256
261
|
"run_mode": run_mode,
|
|
257
262
|
},
|
|
@@ -287,8 +292,20 @@ class AsyncMonitorResource(AsyncAPIResource):
|
|
|
287
292
|
async def create(
|
|
288
293
|
self,
|
|
289
294
|
*,
|
|
295
|
+
guardrail_metrics: List[
|
|
296
|
+
Literal[
|
|
297
|
+
"correctness",
|
|
298
|
+
"completeness",
|
|
299
|
+
"instruction_adherence",
|
|
300
|
+
"context_adherence",
|
|
301
|
+
"ground_truth_adherence",
|
|
302
|
+
"comprehensive_safety",
|
|
303
|
+
]
|
|
304
|
+
],
|
|
290
305
|
name: str,
|
|
291
306
|
description: str | Omit = omit,
|
|
307
|
+
file_search: SequenceNotStr[str] | Omit = omit,
|
|
308
|
+
web_search: bool | Omit = omit,
|
|
292
309
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
293
310
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
294
311
|
extra_headers: Headers | None = None,
|
|
@@ -301,10 +318,20 @@ class AsyncMonitorResource(AsyncAPIResource):
|
|
|
301
318
|
using guardrails
|
|
302
319
|
|
|
303
320
|
Args:
|
|
321
|
+
guardrail_metrics: An array of guardrail metrics that the model input and output pair will be
|
|
322
|
+
evaluated on. For non-enterprise users, these will be limited to `correctness`,
|
|
323
|
+
`completeness`, `instruction_adherence`, `context_adherence`,
|
|
324
|
+
`ground_truth_adherence`, and/or `comprehensive_safety`.
|
|
325
|
+
|
|
304
326
|
name: Name of the new monitor.
|
|
305
327
|
|
|
306
328
|
description: Description of the new monitor.
|
|
307
329
|
|
|
330
|
+
file_search: An array of file IDs to search in the monitor's evaluations. Files must be
|
|
331
|
+
uploaded via the DeepRails API first.
|
|
332
|
+
|
|
333
|
+
web_search: Whether to enable web search for this monitor's evaluations. Defaults to false.
|
|
334
|
+
|
|
308
335
|
extra_headers: Send extra headers
|
|
309
336
|
|
|
310
337
|
extra_query: Add additional query parameters to the request
|
|
@@ -317,8 +344,11 @@ class AsyncMonitorResource(AsyncAPIResource):
|
|
|
317
344
|
"/monitor",
|
|
318
345
|
body=await async_maybe_transform(
|
|
319
346
|
{
|
|
347
|
+
"guardrail_metrics": guardrail_metrics,
|
|
320
348
|
"name": name,
|
|
321
349
|
"description": description,
|
|
350
|
+
"file_search": file_search,
|
|
351
|
+
"web_search": web_search,
|
|
322
352
|
},
|
|
323
353
|
monitor_create_params.MonitorCreateParams,
|
|
324
354
|
),
|
|
@@ -425,19 +455,8 @@ class AsyncMonitorResource(AsyncAPIResource):
|
|
|
425
455
|
self,
|
|
426
456
|
monitor_id: str,
|
|
427
457
|
*,
|
|
428
|
-
guardrail_metrics: List[
|
|
429
|
-
Literal[
|
|
430
|
-
"correctness",
|
|
431
|
-
"completeness",
|
|
432
|
-
"instruction_adherence",
|
|
433
|
-
"context_adherence",
|
|
434
|
-
"ground_truth_adherence",
|
|
435
|
-
"comprehensive_safety",
|
|
436
|
-
]
|
|
437
|
-
],
|
|
438
458
|
model_input: monitor_submit_event_params.ModelInput,
|
|
439
459
|
model_output: str,
|
|
440
|
-
model_used: str | Omit = omit,
|
|
441
460
|
nametag: str | Omit = omit,
|
|
442
461
|
run_mode: Literal["precision_plus", "precision", "smart", "economy"] | Omit = omit,
|
|
443
462
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
@@ -452,19 +471,12 @@ class AsyncMonitorResource(AsyncAPIResource):
|
|
|
452
471
|
evaluation
|
|
453
472
|
|
|
454
473
|
Args:
|
|
455
|
-
guardrail_metrics: An array of guardrail metrics that the model input and output pair will be
|
|
456
|
-
evaluated on. For non-enterprise users, these will be limited to `correctness`,
|
|
457
|
-
`completeness`, `instruction_adherence`, `context_adherence`,
|
|
458
|
-
`ground_truth_adherence`, and/or `comprehensive_safety`.
|
|
459
|
-
|
|
460
474
|
model_input: A dictionary of inputs sent to the LLM to generate output. The dictionary must
|
|
461
475
|
contain at least a `user_prompt` field or a `system_prompt` field. For
|
|
462
476
|
ground_truth_adherence guardrail metric, `ground_truth` should be provided.
|
|
463
477
|
|
|
464
478
|
model_output: Output generated by the LLM to be evaluated.
|
|
465
479
|
|
|
466
|
-
model_used: Model ID used to generate the output, like `gpt-4o` or `o3`.
|
|
467
|
-
|
|
468
480
|
nametag: An optional, user-defined tag for the event.
|
|
469
481
|
|
|
470
482
|
run_mode: Run mode for the monitor event. The run mode allows the user to optimize for
|
|
@@ -486,10 +498,8 @@ class AsyncMonitorResource(AsyncAPIResource):
|
|
|
486
498
|
f"/monitor/{monitor_id}/events",
|
|
487
499
|
body=await async_maybe_transform(
|
|
488
500
|
{
|
|
489
|
-
"guardrail_metrics": guardrail_metrics,
|
|
490
501
|
"model_input": model_input,
|
|
491
502
|
"model_output": model_output,
|
|
492
|
-
"model_used": model_used,
|
|
493
503
|
"nametag": nametag,
|
|
494
504
|
"run_mode": run_mode,
|
|
495
505
|
},
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import List
|
|
6
|
+
from typing_extensions import Literal, Required, TypedDict
|
|
7
|
+
|
|
8
|
+
from .._types import SequenceNotStr
|
|
9
|
+
|
|
10
|
+
__all__ = ["MonitorCreateParams"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class MonitorCreateParams(TypedDict, total=False):
|
|
14
|
+
guardrail_metrics: Required[
|
|
15
|
+
List[
|
|
16
|
+
Literal[
|
|
17
|
+
"correctness",
|
|
18
|
+
"completeness",
|
|
19
|
+
"instruction_adherence",
|
|
20
|
+
"context_adherence",
|
|
21
|
+
"ground_truth_adherence",
|
|
22
|
+
"comprehensive_safety",
|
|
23
|
+
]
|
|
24
|
+
]
|
|
25
|
+
]
|
|
26
|
+
"""
|
|
27
|
+
An array of guardrail metrics that the model input and output pair will be
|
|
28
|
+
evaluated on. For non-enterprise users, these will be limited to `correctness`,
|
|
29
|
+
`completeness`, `instruction_adherence`, `context_adherence`,
|
|
30
|
+
`ground_truth_adherence`, and/or `comprehensive_safety`.
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
name: Required[str]
|
|
34
|
+
"""Name of the new monitor."""
|
|
35
|
+
|
|
36
|
+
description: str
|
|
37
|
+
"""Description of the new monitor."""
|
|
38
|
+
|
|
39
|
+
file_search: SequenceNotStr[str]
|
|
40
|
+
"""An array of file IDs to search in the monitor's evaluations.
|
|
41
|
+
|
|
42
|
+
Files must be uploaded via the DeepRails API first.
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
web_search: bool
|
|
46
|
+
"""Whether to enable web search for this monitor's evaluations. Defaults to false."""
|
|
@@ -2,32 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import List
|
|
6
5
|
from typing_extensions import Literal, Required, TypedDict
|
|
7
6
|
|
|
8
7
|
__all__ = ["MonitorSubmitEventParams", "ModelInput"]
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
class MonitorSubmitEventParams(TypedDict, total=False):
|
|
12
|
-
guardrail_metrics: Required[
|
|
13
|
-
List[
|
|
14
|
-
Literal[
|
|
15
|
-
"correctness",
|
|
16
|
-
"completeness",
|
|
17
|
-
"instruction_adherence",
|
|
18
|
-
"context_adherence",
|
|
19
|
-
"ground_truth_adherence",
|
|
20
|
-
"comprehensive_safety",
|
|
21
|
-
]
|
|
22
|
-
]
|
|
23
|
-
]
|
|
24
|
-
"""
|
|
25
|
-
An array of guardrail metrics that the model input and output pair will be
|
|
26
|
-
evaluated on. For non-enterprise users, these will be limited to `correctness`,
|
|
27
|
-
`completeness`, `instruction_adherence`, `context_adherence`,
|
|
28
|
-
`ground_truth_adherence`, and/or `comprehensive_safety`.
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
11
|
model_input: Required[ModelInput]
|
|
32
12
|
"""A dictionary of inputs sent to the LLM to generate output.
|
|
33
13
|
|
|
@@ -39,9 +19,6 @@ class MonitorSubmitEventParams(TypedDict, total=False):
|
|
|
39
19
|
model_output: Required[str]
|
|
40
20
|
"""Output generated by the LLM to be evaluated."""
|
|
41
21
|
|
|
42
|
-
model_used: str
|
|
43
|
-
"""Model ID used to generate the output, like `gpt-4o` or `o3`."""
|
|
44
|
-
|
|
45
22
|
nametag: str
|
|
46
23
|
"""An optional, user-defined tag for the event."""
|
|
47
24
|
|
|
@@ -25,6 +25,7 @@ class TestMonitor:
|
|
|
25
25
|
@parametrize
|
|
26
26
|
def test_method_create(self, client: Deeprails) -> None:
|
|
27
27
|
monitor = client.monitor.create(
|
|
28
|
+
guardrail_metrics=["correctness"],
|
|
28
29
|
name="name",
|
|
29
30
|
)
|
|
30
31
|
assert_matches_type(MonitorResponse, monitor, path=["response"])
|
|
@@ -33,8 +34,11 @@ class TestMonitor:
|
|
|
33
34
|
@parametrize
|
|
34
35
|
def test_method_create_with_all_params(self, client: Deeprails) -> None:
|
|
35
36
|
monitor = client.monitor.create(
|
|
37
|
+
guardrail_metrics=["correctness"],
|
|
36
38
|
name="name",
|
|
37
39
|
description="description",
|
|
40
|
+
file_search=["string"],
|
|
41
|
+
web_search=True,
|
|
38
42
|
)
|
|
39
43
|
assert_matches_type(MonitorResponse, monitor, path=["response"])
|
|
40
44
|
|
|
@@ -42,6 +46,7 @@ class TestMonitor:
|
|
|
42
46
|
@parametrize
|
|
43
47
|
def test_raw_response_create(self, client: Deeprails) -> None:
|
|
44
48
|
response = client.monitor.with_raw_response.create(
|
|
49
|
+
guardrail_metrics=["correctness"],
|
|
45
50
|
name="name",
|
|
46
51
|
)
|
|
47
52
|
|
|
@@ -54,6 +59,7 @@ class TestMonitor:
|
|
|
54
59
|
@parametrize
|
|
55
60
|
def test_streaming_response_create(self, client: Deeprails) -> None:
|
|
56
61
|
with client.monitor.with_streaming_response.create(
|
|
62
|
+
guardrail_metrics=["correctness"],
|
|
57
63
|
name="name",
|
|
58
64
|
) as response:
|
|
59
65
|
assert not response.is_closed
|
|
@@ -173,7 +179,6 @@ class TestMonitor:
|
|
|
173
179
|
def test_method_submit_event(self, client: Deeprails) -> None:
|
|
174
180
|
monitor = client.monitor.submit_event(
|
|
175
181
|
monitor_id="monitor_id",
|
|
176
|
-
guardrail_metrics=["correctness"],
|
|
177
182
|
model_input={},
|
|
178
183
|
model_output="model_output",
|
|
179
184
|
)
|
|
@@ -184,14 +189,12 @@ class TestMonitor:
|
|
|
184
189
|
def test_method_submit_event_with_all_params(self, client: Deeprails) -> None:
|
|
185
190
|
monitor = client.monitor.submit_event(
|
|
186
191
|
monitor_id="monitor_id",
|
|
187
|
-
guardrail_metrics=["correctness"],
|
|
188
192
|
model_input={
|
|
189
193
|
"ground_truth": "ground_truth",
|
|
190
194
|
"system_prompt": "system_prompt",
|
|
191
195
|
"user_prompt": "user_prompt",
|
|
192
196
|
},
|
|
193
197
|
model_output="model_output",
|
|
194
|
-
model_used="model_used",
|
|
195
198
|
nametag="nametag",
|
|
196
199
|
run_mode="precision_plus",
|
|
197
200
|
)
|
|
@@ -202,7 +205,6 @@ class TestMonitor:
|
|
|
202
205
|
def test_raw_response_submit_event(self, client: Deeprails) -> None:
|
|
203
206
|
response = client.monitor.with_raw_response.submit_event(
|
|
204
207
|
monitor_id="monitor_id",
|
|
205
|
-
guardrail_metrics=["correctness"],
|
|
206
208
|
model_input={},
|
|
207
209
|
model_output="model_output",
|
|
208
210
|
)
|
|
@@ -217,7 +219,6 @@ class TestMonitor:
|
|
|
217
219
|
def test_streaming_response_submit_event(self, client: Deeprails) -> None:
|
|
218
220
|
with client.monitor.with_streaming_response.submit_event(
|
|
219
221
|
monitor_id="monitor_id",
|
|
220
|
-
guardrail_metrics=["correctness"],
|
|
221
222
|
model_input={},
|
|
222
223
|
model_output="model_output",
|
|
223
224
|
) as response:
|
|
@@ -235,7 +236,6 @@ class TestMonitor:
|
|
|
235
236
|
with pytest.raises(ValueError, match=r"Expected a non-empty value for `monitor_id` but received ''"):
|
|
236
237
|
client.monitor.with_raw_response.submit_event(
|
|
237
238
|
monitor_id="",
|
|
238
|
-
guardrail_metrics=["correctness"],
|
|
239
239
|
model_input={},
|
|
240
240
|
model_output="model_output",
|
|
241
241
|
)
|
|
@@ -250,6 +250,7 @@ class TestAsyncMonitor:
|
|
|
250
250
|
@parametrize
|
|
251
251
|
async def test_method_create(self, async_client: AsyncDeeprails) -> None:
|
|
252
252
|
monitor = await async_client.monitor.create(
|
|
253
|
+
guardrail_metrics=["correctness"],
|
|
253
254
|
name="name",
|
|
254
255
|
)
|
|
255
256
|
assert_matches_type(MonitorResponse, monitor, path=["response"])
|
|
@@ -258,8 +259,11 @@ class TestAsyncMonitor:
|
|
|
258
259
|
@parametrize
|
|
259
260
|
async def test_method_create_with_all_params(self, async_client: AsyncDeeprails) -> None:
|
|
260
261
|
monitor = await async_client.monitor.create(
|
|
262
|
+
guardrail_metrics=["correctness"],
|
|
261
263
|
name="name",
|
|
262
264
|
description="description",
|
|
265
|
+
file_search=["string"],
|
|
266
|
+
web_search=True,
|
|
263
267
|
)
|
|
264
268
|
assert_matches_type(MonitorResponse, monitor, path=["response"])
|
|
265
269
|
|
|
@@ -267,6 +271,7 @@ class TestAsyncMonitor:
|
|
|
267
271
|
@parametrize
|
|
268
272
|
async def test_raw_response_create(self, async_client: AsyncDeeprails) -> None:
|
|
269
273
|
response = await async_client.monitor.with_raw_response.create(
|
|
274
|
+
guardrail_metrics=["correctness"],
|
|
270
275
|
name="name",
|
|
271
276
|
)
|
|
272
277
|
|
|
@@ -279,6 +284,7 @@ class TestAsyncMonitor:
|
|
|
279
284
|
@parametrize
|
|
280
285
|
async def test_streaming_response_create(self, async_client: AsyncDeeprails) -> None:
|
|
281
286
|
async with async_client.monitor.with_streaming_response.create(
|
|
287
|
+
guardrail_metrics=["correctness"],
|
|
282
288
|
name="name",
|
|
283
289
|
) as response:
|
|
284
290
|
assert not response.is_closed
|
|
@@ -398,7 +404,6 @@ class TestAsyncMonitor:
|
|
|
398
404
|
async def test_method_submit_event(self, async_client: AsyncDeeprails) -> None:
|
|
399
405
|
monitor = await async_client.monitor.submit_event(
|
|
400
406
|
monitor_id="monitor_id",
|
|
401
|
-
guardrail_metrics=["correctness"],
|
|
402
407
|
model_input={},
|
|
403
408
|
model_output="model_output",
|
|
404
409
|
)
|
|
@@ -409,14 +414,12 @@ class TestAsyncMonitor:
|
|
|
409
414
|
async def test_method_submit_event_with_all_params(self, async_client: AsyncDeeprails) -> None:
|
|
410
415
|
monitor = await async_client.monitor.submit_event(
|
|
411
416
|
monitor_id="monitor_id",
|
|
412
|
-
guardrail_metrics=["correctness"],
|
|
413
417
|
model_input={
|
|
414
418
|
"ground_truth": "ground_truth",
|
|
415
419
|
"system_prompt": "system_prompt",
|
|
416
420
|
"user_prompt": "user_prompt",
|
|
417
421
|
},
|
|
418
422
|
model_output="model_output",
|
|
419
|
-
model_used="model_used",
|
|
420
423
|
nametag="nametag",
|
|
421
424
|
run_mode="precision_plus",
|
|
422
425
|
)
|
|
@@ -427,7 +430,6 @@ class TestAsyncMonitor:
|
|
|
427
430
|
async def test_raw_response_submit_event(self, async_client: AsyncDeeprails) -> None:
|
|
428
431
|
response = await async_client.monitor.with_raw_response.submit_event(
|
|
429
432
|
monitor_id="monitor_id",
|
|
430
|
-
guardrail_metrics=["correctness"],
|
|
431
433
|
model_input={},
|
|
432
434
|
model_output="model_output",
|
|
433
435
|
)
|
|
@@ -442,7 +444,6 @@ class TestAsyncMonitor:
|
|
|
442
444
|
async def test_streaming_response_submit_event(self, async_client: AsyncDeeprails) -> None:
|
|
443
445
|
async with async_client.monitor.with_streaming_response.submit_event(
|
|
444
446
|
monitor_id="monitor_id",
|
|
445
|
-
guardrail_metrics=["correctness"],
|
|
446
447
|
model_input={},
|
|
447
448
|
model_output="model_output",
|
|
448
449
|
) as response:
|
|
@@ -460,7 +461,6 @@ class TestAsyncMonitor:
|
|
|
460
461
|
with pytest.raises(ValueError, match=r"Expected a non-empty value for `monitor_id` but received ''"):
|
|
461
462
|
await async_client.monitor.with_raw_response.submit_event(
|
|
462
463
|
monitor_id="",
|
|
463
|
-
guardrail_metrics=["correctness"],
|
|
464
464
|
model_input={},
|
|
465
465
|
model_output="model_output",
|
|
466
466
|
)
|