deeprails 0.3.2__py3-none-any.whl → 1.0.0__py3-none-any.whl

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.

Files changed (60) hide show
  1. deeprails/__init__.py +104 -1
  2. deeprails/_base_client.py +1995 -0
  3. deeprails/_client.py +478 -0
  4. deeprails/_compat.py +219 -0
  5. deeprails/_constants.py +14 -0
  6. deeprails/_exceptions.py +108 -0
  7. deeprails/_files.py +123 -0
  8. deeprails/_models.py +835 -0
  9. deeprails/_qs.py +150 -0
  10. deeprails/_resource.py +43 -0
  11. deeprails/_response.py +830 -0
  12. deeprails/_streaming.py +333 -0
  13. deeprails/_types.py +260 -0
  14. deeprails/_utils/__init__.py +64 -0
  15. deeprails/_utils/_compat.py +45 -0
  16. deeprails/_utils/_datetime_parse.py +136 -0
  17. deeprails/_utils/_logs.py +25 -0
  18. deeprails/_utils/_proxy.py +65 -0
  19. deeprails/_utils/_reflection.py +42 -0
  20. deeprails/_utils/_resources_proxy.py +24 -0
  21. deeprails/_utils/_streams.py +12 -0
  22. deeprails/_utils/_sync.py +86 -0
  23. deeprails/_utils/_transform.py +457 -0
  24. deeprails/_utils/_typing.py +156 -0
  25. deeprails/_utils/_utils.py +421 -0
  26. deeprails/_version.py +4 -0
  27. deeprails/lib/.keep +4 -0
  28. deeprails/py.typed +0 -0
  29. deeprails/resources/__init__.py +47 -0
  30. deeprails/resources/defend/__init__.py +33 -0
  31. deeprails/resources/defend/defend.py +480 -0
  32. deeprails/resources/defend/events.py +311 -0
  33. deeprails/resources/evaluate.py +334 -0
  34. deeprails/resources/monitor.py +566 -0
  35. deeprails/types/__init__.py +16 -0
  36. deeprails/types/api_response.py +50 -0
  37. deeprails/types/defend/__init__.py +6 -0
  38. deeprails/types/defend/event_submit_event_params.py +44 -0
  39. deeprails/types/defend/workflow_event_response.py +33 -0
  40. deeprails/types/defend_create_workflow_params.py +56 -0
  41. deeprails/types/defend_response.py +50 -0
  42. deeprails/types/defend_update_workflow_params.py +18 -0
  43. deeprails/types/evaluate_create_params.py +60 -0
  44. deeprails/types/evaluation.py +113 -0
  45. deeprails/types/monitor_create_params.py +15 -0
  46. deeprails/types/monitor_retrieve_params.py +12 -0
  47. deeprails/types/monitor_retrieve_response.py +81 -0
  48. deeprails/types/monitor_submit_event_params.py +63 -0
  49. deeprails/types/monitor_submit_event_response.py +36 -0
  50. deeprails/types/monitor_update_params.py +22 -0
  51. deeprails-1.0.0.dist-info/METADATA +550 -0
  52. deeprails-1.0.0.dist-info/RECORD +54 -0
  53. {deeprails-0.3.2.dist-info → deeprails-1.0.0.dist-info}/WHEEL +1 -1
  54. deeprails-1.0.0.dist-info/licenses/LICENSE +201 -0
  55. deeprails/client.py +0 -285
  56. deeprails/exceptions.py +0 -10
  57. deeprails/schemas.py +0 -92
  58. deeprails-0.3.2.dist-info/METADATA +0 -235
  59. deeprails-0.3.2.dist-info/RECORD +0 -8
  60. deeprails-0.3.2.dist-info/licenses/LICENSE +0 -11
@@ -0,0 +1,566 @@
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
7
+
8
+ import httpx
9
+
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
12
+ from .._utils import maybe_transform, async_maybe_transform
13
+ from .._compat import cached_property
14
+ from .._resource import SyncAPIResource, AsyncAPIResource
15
+ from .._response import (
16
+ to_raw_response_wrapper,
17
+ to_streamed_response_wrapper,
18
+ async_to_raw_response_wrapper,
19
+ async_to_streamed_response_wrapper,
20
+ )
21
+ from .._base_client import make_request_options
22
+ from ..types.api_response import APIResponse
23
+ from ..types.monitor_retrieve_response import MonitorRetrieveResponse
24
+ from ..types.monitor_submit_event_response import MonitorSubmitEventResponse
25
+
26
+ __all__ = ["MonitorResource", "AsyncMonitorResource"]
27
+
28
+
29
+ class MonitorResource(SyncAPIResource):
30
+ @cached_property
31
+ def with_raw_response(self) -> MonitorResourceWithRawResponse:
32
+ """
33
+ This property can be used as a prefix for any HTTP method call to return
34
+ the raw response object instead of the parsed content.
35
+
36
+ For more information, see https://www.github.com/deeprails/deeprails-python-sdk#accessing-raw-response-data-eg-headers
37
+ """
38
+ return MonitorResourceWithRawResponse(self)
39
+
40
+ @cached_property
41
+ def with_streaming_response(self) -> MonitorResourceWithStreamingResponse:
42
+ """
43
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
44
+
45
+ For more information, see https://www.github.com/deeprails/deeprails-python-sdk#with_streaming_response
46
+ """
47
+ return MonitorResourceWithStreamingResponse(self)
48
+
49
+ def create(
50
+ self,
51
+ *,
52
+ name: str,
53
+ description: str | Omit = omit,
54
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
55
+ # The extra values given here take precedence over values defined on the client or passed to this method.
56
+ extra_headers: Headers | None = None,
57
+ extra_query: Query | None = None,
58
+ extra_body: Body | None = None,
59
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
60
+ ) -> APIResponse:
61
+ """
62
+ Create a new monitor to evaluate model inputs and outputs using guardrails.
63
+
64
+ Args:
65
+ name: Name of the new monitor.
66
+
67
+ description: Description of the new monitor.
68
+
69
+ extra_headers: Send extra headers
70
+
71
+ extra_query: Add additional query parameters to the request
72
+
73
+ extra_body: Add additional JSON properties to the request
74
+
75
+ timeout: Override the client-level default timeout for this request, in seconds
76
+ """
77
+ return self._post(
78
+ "/monitor",
79
+ body=maybe_transform(
80
+ {
81
+ "name": name,
82
+ "description": description,
83
+ },
84
+ monitor_create_params.MonitorCreateParams,
85
+ ),
86
+ options=make_request_options(
87
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
88
+ ),
89
+ cast_to=APIResponse,
90
+ )
91
+
92
+ def retrieve(
93
+ self,
94
+ monitor_id: str,
95
+ *,
96
+ limit: int | Omit = omit,
97
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
98
+ # The extra values given here take precedence over values defined on the client or passed to this method.
99
+ extra_headers: Headers | None = None,
100
+ extra_query: Query | None = None,
101
+ extra_body: Body | None = None,
102
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
103
+ ) -> MonitorRetrieveResponse:
104
+ """
105
+ Retrieve the details and evaluations associated with a specific monitor.
106
+
107
+ Args:
108
+ limit: Limit the returned events associated with this monitor. Defaults to 10.
109
+
110
+ extra_headers: Send extra headers
111
+
112
+ extra_query: Add additional query parameters to the request
113
+
114
+ extra_body: Add additional JSON properties to the request
115
+
116
+ timeout: Override the client-level default timeout for this request, in seconds
117
+ """
118
+ if not monitor_id:
119
+ raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}")
120
+ return self._get(
121
+ f"/monitor/{monitor_id}",
122
+ options=make_request_options(
123
+ extra_headers=extra_headers,
124
+ extra_query=extra_query,
125
+ extra_body=extra_body,
126
+ timeout=timeout,
127
+ query=maybe_transform({"limit": limit}, monitor_retrieve_params.MonitorRetrieveParams),
128
+ ),
129
+ cast_to=MonitorRetrieveResponse,
130
+ )
131
+
132
+ def update(
133
+ self,
134
+ monitor_id: str,
135
+ *,
136
+ description: str | Omit = omit,
137
+ monitor_status: Literal["active", "inactive"] | Omit = omit,
138
+ name: str | Omit = omit,
139
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
140
+ # The extra values given here take precedence over values defined on the client or passed to this method.
141
+ extra_headers: Headers | None = None,
142
+ extra_query: Query | None = None,
143
+ extra_body: Body | None = None,
144
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
145
+ ) -> APIResponse:
146
+ """
147
+ Update the name, description, or status of an existing monitor.
148
+
149
+ Args:
150
+ description: Description of the monitor.
151
+
152
+ monitor_status: Status of the monitor. Can be `active` or `inactive`. Inactive monitors no
153
+ longer record and evaluate events.
154
+
155
+ name: Name of the monitor.
156
+
157
+ extra_headers: Send extra headers
158
+
159
+ extra_query: Add additional query parameters to the request
160
+
161
+ extra_body: Add additional JSON properties to the request
162
+
163
+ timeout: Override the client-level default timeout for this request, in seconds
164
+ """
165
+ if not monitor_id:
166
+ raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}")
167
+ return self._put(
168
+ f"/monitor/{monitor_id}",
169
+ body=maybe_transform(
170
+ {
171
+ "description": description,
172
+ "monitor_status": monitor_status,
173
+ "name": name,
174
+ },
175
+ monitor_update_params.MonitorUpdateParams,
176
+ ),
177
+ options=make_request_options(
178
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
179
+ ),
180
+ cast_to=APIResponse,
181
+ )
182
+
183
+ def submit_event(
184
+ self,
185
+ monitor_id: str,
186
+ *,
187
+ guardrail_metrics: List[
188
+ Literal[
189
+ "correctness",
190
+ "completeness",
191
+ "instruction_adherence",
192
+ "context_adherence",
193
+ "ground_truth_adherence",
194
+ "comprehensive_safety",
195
+ ]
196
+ ],
197
+ model_input: monitor_submit_event_params.ModelInput,
198
+ model_output: str,
199
+ model_used: str | Omit = omit,
200
+ nametag: str | Omit = omit,
201
+ run_mode: Literal["precision_plus", "precision", "smart", "economy"] | Omit = omit,
202
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
203
+ # The extra values given here take precedence over values defined on the client or passed to this method.
204
+ extra_headers: Headers | None = None,
205
+ extra_query: Query | None = None,
206
+ extra_body: Body | None = None,
207
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
208
+ ) -> MonitorSubmitEventResponse:
209
+ """
210
+ Submit a model input and output pair to a monitor for evaluation.
211
+
212
+ Args:
213
+ guardrail_metrics: An array of guardrail metrics that the model input and output pair will be
214
+ evaluated on. For non-enterprise users, these will be limited to `correctness`,
215
+ `completeness`, `instruction_adherence`, `context_adherence`,
216
+ `ground_truth_adherence`, and/or `comprehensive_safety`.
217
+
218
+ model_input: A dictionary of inputs sent to the LLM to generate output. This must contain a
219
+ `user_prompt` field and an optional `context` field. Additional properties are
220
+ allowed.
221
+
222
+ model_output: Output generated by the LLM to be evaluated.
223
+
224
+ model_used: Model ID used to generate the output, like `gpt-4o` or `o3`.
225
+
226
+ nametag: An optional, user-defined tag for the event.
227
+
228
+ run_mode: Run mode for the monitor event. The run mode allows the user to optimize for
229
+ speed, accuracy, and cost by determining which models are used to evaluate the
230
+ event. Available run modes include `precision_plus`, `precision`, `smart`, and
231
+ `economy`. Defaults to `smart`.
232
+
233
+ extra_headers: Send extra headers
234
+
235
+ extra_query: Add additional query parameters to the request
236
+
237
+ extra_body: Add additional JSON properties to the request
238
+
239
+ timeout: Override the client-level default timeout for this request, in seconds
240
+ """
241
+ if not monitor_id:
242
+ raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}")
243
+ return self._post(
244
+ f"/monitor/{monitor_id}/events",
245
+ body=maybe_transform(
246
+ {
247
+ "guardrail_metrics": guardrail_metrics,
248
+ "model_input": model_input,
249
+ "model_output": model_output,
250
+ "model_used": model_used,
251
+ "nametag": nametag,
252
+ "run_mode": run_mode,
253
+ },
254
+ monitor_submit_event_params.MonitorSubmitEventParams,
255
+ ),
256
+ options=make_request_options(
257
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
258
+ ),
259
+ cast_to=MonitorSubmitEventResponse,
260
+ )
261
+
262
+
263
+ class AsyncMonitorResource(AsyncAPIResource):
264
+ @cached_property
265
+ def with_raw_response(self) -> AsyncMonitorResourceWithRawResponse:
266
+ """
267
+ This property can be used as a prefix for any HTTP method call to return
268
+ the raw response object instead of the parsed content.
269
+
270
+ For more information, see https://www.github.com/deeprails/deeprails-python-sdk#accessing-raw-response-data-eg-headers
271
+ """
272
+ return AsyncMonitorResourceWithRawResponse(self)
273
+
274
+ @cached_property
275
+ def with_streaming_response(self) -> AsyncMonitorResourceWithStreamingResponse:
276
+ """
277
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
278
+
279
+ For more information, see https://www.github.com/deeprails/deeprails-python-sdk#with_streaming_response
280
+ """
281
+ return AsyncMonitorResourceWithStreamingResponse(self)
282
+
283
+ async def create(
284
+ self,
285
+ *,
286
+ name: str,
287
+ description: str | Omit = omit,
288
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
289
+ # The extra values given here take precedence over values defined on the client or passed to this method.
290
+ extra_headers: Headers | None = None,
291
+ extra_query: Query | None = None,
292
+ extra_body: Body | None = None,
293
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
294
+ ) -> APIResponse:
295
+ """
296
+ Create a new monitor to evaluate model inputs and outputs using guardrails.
297
+
298
+ Args:
299
+ name: Name of the new monitor.
300
+
301
+ description: Description of the new monitor.
302
+
303
+ extra_headers: Send extra headers
304
+
305
+ extra_query: Add additional query parameters to the request
306
+
307
+ extra_body: Add additional JSON properties to the request
308
+
309
+ timeout: Override the client-level default timeout for this request, in seconds
310
+ """
311
+ return await self._post(
312
+ "/monitor",
313
+ body=await async_maybe_transform(
314
+ {
315
+ "name": name,
316
+ "description": description,
317
+ },
318
+ monitor_create_params.MonitorCreateParams,
319
+ ),
320
+ options=make_request_options(
321
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
322
+ ),
323
+ cast_to=APIResponse,
324
+ )
325
+
326
+ async def retrieve(
327
+ self,
328
+ monitor_id: str,
329
+ *,
330
+ limit: int | Omit = omit,
331
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
332
+ # The extra values given here take precedence over values defined on the client or passed to this method.
333
+ extra_headers: Headers | None = None,
334
+ extra_query: Query | None = None,
335
+ extra_body: Body | None = None,
336
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
337
+ ) -> MonitorRetrieveResponse:
338
+ """
339
+ Retrieve the details and evaluations associated with a specific monitor.
340
+
341
+ Args:
342
+ limit: Limit the returned events associated with this monitor. Defaults to 10.
343
+
344
+ extra_headers: Send extra headers
345
+
346
+ extra_query: Add additional query parameters to the request
347
+
348
+ extra_body: Add additional JSON properties to the request
349
+
350
+ timeout: Override the client-level default timeout for this request, in seconds
351
+ """
352
+ if not monitor_id:
353
+ raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}")
354
+ return await self._get(
355
+ f"/monitor/{monitor_id}",
356
+ options=make_request_options(
357
+ extra_headers=extra_headers,
358
+ extra_query=extra_query,
359
+ extra_body=extra_body,
360
+ timeout=timeout,
361
+ query=await async_maybe_transform({"limit": limit}, monitor_retrieve_params.MonitorRetrieveParams),
362
+ ),
363
+ cast_to=MonitorRetrieveResponse,
364
+ )
365
+
366
+ async def update(
367
+ self,
368
+ monitor_id: str,
369
+ *,
370
+ description: str | Omit = omit,
371
+ monitor_status: Literal["active", "inactive"] | Omit = omit,
372
+ name: str | Omit = omit,
373
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
374
+ # The extra values given here take precedence over values defined on the client or passed to this method.
375
+ extra_headers: Headers | None = None,
376
+ extra_query: Query | None = None,
377
+ extra_body: Body | None = None,
378
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
379
+ ) -> APIResponse:
380
+ """
381
+ Update the name, description, or status of an existing monitor.
382
+
383
+ Args:
384
+ description: Description of the monitor.
385
+
386
+ monitor_status: Status of the monitor. Can be `active` or `inactive`. Inactive monitors no
387
+ longer record and evaluate events.
388
+
389
+ name: Name of the monitor.
390
+
391
+ extra_headers: Send extra headers
392
+
393
+ extra_query: Add additional query parameters to the request
394
+
395
+ extra_body: Add additional JSON properties to the request
396
+
397
+ timeout: Override the client-level default timeout for this request, in seconds
398
+ """
399
+ if not monitor_id:
400
+ raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}")
401
+ return await self._put(
402
+ f"/monitor/{monitor_id}",
403
+ body=await async_maybe_transform(
404
+ {
405
+ "description": description,
406
+ "monitor_status": monitor_status,
407
+ "name": name,
408
+ },
409
+ monitor_update_params.MonitorUpdateParams,
410
+ ),
411
+ options=make_request_options(
412
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
413
+ ),
414
+ cast_to=APIResponse,
415
+ )
416
+
417
+ async def submit_event(
418
+ self,
419
+ monitor_id: str,
420
+ *,
421
+ guardrail_metrics: List[
422
+ Literal[
423
+ "correctness",
424
+ "completeness",
425
+ "instruction_adherence",
426
+ "context_adherence",
427
+ "ground_truth_adherence",
428
+ "comprehensive_safety",
429
+ ]
430
+ ],
431
+ model_input: monitor_submit_event_params.ModelInput,
432
+ model_output: str,
433
+ model_used: str | Omit = omit,
434
+ nametag: str | Omit = omit,
435
+ run_mode: Literal["precision_plus", "precision", "smart", "economy"] | Omit = omit,
436
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
437
+ # The extra values given here take precedence over values defined on the client or passed to this method.
438
+ extra_headers: Headers | None = None,
439
+ extra_query: Query | None = None,
440
+ extra_body: Body | None = None,
441
+ timeout: float | httpx.Timeout | None | NotGiven = not_given,
442
+ ) -> MonitorSubmitEventResponse:
443
+ """
444
+ Submit a model input and output pair to a monitor for evaluation.
445
+
446
+ Args:
447
+ guardrail_metrics: An array of guardrail metrics that the model input and output pair will be
448
+ evaluated on. For non-enterprise users, these will be limited to `correctness`,
449
+ `completeness`, `instruction_adherence`, `context_adherence`,
450
+ `ground_truth_adherence`, and/or `comprehensive_safety`.
451
+
452
+ model_input: A dictionary of inputs sent to the LLM to generate output. This must contain a
453
+ `user_prompt` field and an optional `context` field. Additional properties are
454
+ allowed.
455
+
456
+ model_output: Output generated by the LLM to be evaluated.
457
+
458
+ model_used: Model ID used to generate the output, like `gpt-4o` or `o3`.
459
+
460
+ nametag: An optional, user-defined tag for the event.
461
+
462
+ run_mode: Run mode for the monitor event. The run mode allows the user to optimize for
463
+ speed, accuracy, and cost by determining which models are used to evaluate the
464
+ event. Available run modes include `precision_plus`, `precision`, `smart`, and
465
+ `economy`. Defaults to `smart`.
466
+
467
+ extra_headers: Send extra headers
468
+
469
+ extra_query: Add additional query parameters to the request
470
+
471
+ extra_body: Add additional JSON properties to the request
472
+
473
+ timeout: Override the client-level default timeout for this request, in seconds
474
+ """
475
+ if not monitor_id:
476
+ raise ValueError(f"Expected a non-empty value for `monitor_id` but received {monitor_id!r}")
477
+ return await self._post(
478
+ f"/monitor/{monitor_id}/events",
479
+ body=await async_maybe_transform(
480
+ {
481
+ "guardrail_metrics": guardrail_metrics,
482
+ "model_input": model_input,
483
+ "model_output": model_output,
484
+ "model_used": model_used,
485
+ "nametag": nametag,
486
+ "run_mode": run_mode,
487
+ },
488
+ monitor_submit_event_params.MonitorSubmitEventParams,
489
+ ),
490
+ options=make_request_options(
491
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
492
+ ),
493
+ cast_to=MonitorSubmitEventResponse,
494
+ )
495
+
496
+
497
+ class MonitorResourceWithRawResponse:
498
+ def __init__(self, monitor: MonitorResource) -> None:
499
+ self._monitor = monitor
500
+
501
+ self.create = to_raw_response_wrapper(
502
+ monitor.create,
503
+ )
504
+ self.retrieve = to_raw_response_wrapper(
505
+ monitor.retrieve,
506
+ )
507
+ self.update = to_raw_response_wrapper(
508
+ monitor.update,
509
+ )
510
+ self.submit_event = to_raw_response_wrapper(
511
+ monitor.submit_event,
512
+ )
513
+
514
+
515
+ class AsyncMonitorResourceWithRawResponse:
516
+ def __init__(self, monitor: AsyncMonitorResource) -> None:
517
+ self._monitor = monitor
518
+
519
+ self.create = async_to_raw_response_wrapper(
520
+ monitor.create,
521
+ )
522
+ self.retrieve = async_to_raw_response_wrapper(
523
+ monitor.retrieve,
524
+ )
525
+ self.update = async_to_raw_response_wrapper(
526
+ monitor.update,
527
+ )
528
+ self.submit_event = async_to_raw_response_wrapper(
529
+ monitor.submit_event,
530
+ )
531
+
532
+
533
+ class MonitorResourceWithStreamingResponse:
534
+ def __init__(self, monitor: MonitorResource) -> None:
535
+ self._monitor = monitor
536
+
537
+ self.create = to_streamed_response_wrapper(
538
+ monitor.create,
539
+ )
540
+ self.retrieve = to_streamed_response_wrapper(
541
+ monitor.retrieve,
542
+ )
543
+ self.update = to_streamed_response_wrapper(
544
+ monitor.update,
545
+ )
546
+ self.submit_event = to_streamed_response_wrapper(
547
+ monitor.submit_event,
548
+ )
549
+
550
+
551
+ class AsyncMonitorResourceWithStreamingResponse:
552
+ def __init__(self, monitor: AsyncMonitorResource) -> None:
553
+ self._monitor = monitor
554
+
555
+ self.create = async_to_streamed_response_wrapper(
556
+ monitor.create,
557
+ )
558
+ self.retrieve = async_to_streamed_response_wrapper(
559
+ monitor.retrieve,
560
+ )
561
+ self.update = async_to_streamed_response_wrapper(
562
+ monitor.update,
563
+ )
564
+ self.submit_event = async_to_streamed_response_wrapper(
565
+ monitor.submit_event,
566
+ )
@@ -0,0 +1,16 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from .evaluation import Evaluation as Evaluation
6
+ from .api_response import APIResponse as APIResponse
7
+ from .defend_response import DefendResponse as DefendResponse
8
+ from .monitor_create_params import MonitorCreateParams as MonitorCreateParams
9
+ from .monitor_update_params import MonitorUpdateParams as MonitorUpdateParams
10
+ from .evaluate_create_params import EvaluateCreateParams as EvaluateCreateParams
11
+ from .monitor_retrieve_params import MonitorRetrieveParams as MonitorRetrieveParams
12
+ from .monitor_retrieve_response import MonitorRetrieveResponse as MonitorRetrieveResponse
13
+ from .monitor_submit_event_params import MonitorSubmitEventParams as MonitorSubmitEventParams
14
+ from .defend_create_workflow_params import DefendCreateWorkflowParams as DefendCreateWorkflowParams
15
+ from .defend_update_workflow_params import DefendUpdateWorkflowParams as DefendUpdateWorkflowParams
16
+ from .monitor_submit_event_response import MonitorSubmitEventResponse as MonitorSubmitEventResponse
@@ -0,0 +1,50 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Optional
4
+ from datetime import datetime
5
+ from typing_extensions import Literal
6
+
7
+ from .._models import BaseModel
8
+
9
+ __all__ = ["APIResponse", "Data"]
10
+
11
+
12
+ class Data(BaseModel):
13
+ monitor_id: str
14
+ """A unique monitor ID."""
15
+
16
+ name: str
17
+ """Name of the monitor."""
18
+
19
+ created_at: Optional[datetime] = None
20
+ """The time the monitor was created in UTC."""
21
+
22
+ description: Optional[str] = None
23
+ """Description of the monitor."""
24
+
25
+ monitor_status: Optional[Literal["active", "inactive"]] = None
26
+ """Status of the monitor.
27
+
28
+ Can be `active` or `inactive`. Inactive monitors no longer record and evaluate
29
+ events.
30
+ """
31
+
32
+ updated_at: Optional[datetime] = None
33
+ """The most recent time the monitor was modified in UTC."""
34
+
35
+ user_id: Optional[str] = None
36
+ """User ID of the user who created the monitor."""
37
+
38
+
39
+ class APIResponse(BaseModel):
40
+ success: bool
41
+ """Represents whether the request was completed successfully."""
42
+
43
+ data: Optional[Data] = None
44
+ """Response payload for creating or updating a monitor."""
45
+
46
+ message: Optional[str] = None
47
+ """The accompanying message for the request.
48
+
49
+ Includes error details when applicable.
50
+ """
@@ -0,0 +1,6 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from .workflow_event_response import WorkflowEventResponse as WorkflowEventResponse
6
+ from .event_submit_event_params import EventSubmitEventParams as EventSubmitEventParams
@@ -0,0 +1,44 @@
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 Dict, Union
6
+ from typing_extensions import Literal, Required, TypeAlias, TypedDict
7
+
8
+ __all__ = ["EventSubmitEventParams", "ModelInput"]
9
+
10
+
11
+ class EventSubmitEventParams(TypedDict, total=False):
12
+ model_input: Required[ModelInput]
13
+ """A dictionary of inputs sent to the LLM to generate output.
14
+
15
+ This must contain a `user_prompt` field and an optional `context` field.
16
+ Additional properties are allowed.
17
+ """
18
+
19
+ model_output: Required[str]
20
+ """Output generated by the LLM to be evaluated."""
21
+
22
+ model_used: Required[str]
23
+ """Model ID used to generate the output, like `gpt-4o` or `o3`."""
24
+
25
+ nametag: Required[str]
26
+ """An optional, user-defined tag for the event."""
27
+
28
+ run_mode: Required[Literal["precision_plus", "precision", "smart", "economy"]]
29
+ """Run mode for the workflow event.
30
+
31
+ The run mode allows the user to optimize for speed, accuracy, and cost by
32
+ determining which models are used to evaluate the event. Available run modes
33
+ include `precision_plus`, `precision`, `smart`, and `economy`. Defaults to
34
+ `smart`.
35
+ """
36
+
37
+
38
+ class ModelInputTyped(TypedDict, total=False):
39
+ user_prompt: Required[str]
40
+
41
+ context: str
42
+
43
+
44
+ ModelInput: TypeAlias = Union[ModelInputTyped, Dict[str, object]]