deeprails 1.0.0__py3-none-any.whl → 1.2.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.
- deeprails/__init__.py +0 -2
- deeprails/_client.py +13 -72
- deeprails/_version.py +1 -1
- deeprails/resources/{defend/defend.py → defend.py} +235 -44
- deeprails/resources/evaluate.py +4 -4
- deeprails/resources/monitor.py +4 -4
- deeprails/types/__init__.py +2 -0
- deeprails/types/{defend/event_submit_event_params.py → defend_submit_event_params.py} +2 -2
- deeprails/types/{defend/workflow_event_response.py → workflow_event_response.py} +1 -1
- {deeprails-1.0.0.dist-info → deeprails-1.2.0.dist-info}/METADATA +50 -223
- {deeprails-1.0.0.dist-info → deeprails-1.2.0.dist-info}/RECORD +13 -16
- deeprails/resources/defend/__init__.py +0 -33
- deeprails/resources/defend/events.py +0 -311
- deeprails/types/defend/__init__.py +0 -6
- {deeprails-1.0.0.dist-info → deeprails-1.2.0.dist-info}/WHEEL +0 -0
- {deeprails-1.0.0.dist-info → deeprails-1.2.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
-
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
from typing_extensions import Literal
|
|
6
|
-
|
|
7
|
-
import httpx
|
|
8
|
-
|
|
9
|
-
from ..._types import Body, Query, Headers, NotGiven, not_given
|
|
10
|
-
from ..._utils import maybe_transform, async_maybe_transform
|
|
11
|
-
from ..._compat import cached_property
|
|
12
|
-
from ..._resource import SyncAPIResource, AsyncAPIResource
|
|
13
|
-
from ..._response import (
|
|
14
|
-
to_raw_response_wrapper,
|
|
15
|
-
to_streamed_response_wrapper,
|
|
16
|
-
async_to_raw_response_wrapper,
|
|
17
|
-
async_to_streamed_response_wrapper,
|
|
18
|
-
)
|
|
19
|
-
from ..._base_client import make_request_options
|
|
20
|
-
from ...types.defend import event_submit_event_params
|
|
21
|
-
from ...types.defend.workflow_event_response import WorkflowEventResponse
|
|
22
|
-
|
|
23
|
-
__all__ = ["EventsResource", "AsyncEventsResource"]
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class EventsResource(SyncAPIResource):
|
|
27
|
-
@cached_property
|
|
28
|
-
def with_raw_response(self) -> EventsResourceWithRawResponse:
|
|
29
|
-
"""
|
|
30
|
-
This property can be used as a prefix for any HTTP method call to return
|
|
31
|
-
the raw response object instead of the parsed content.
|
|
32
|
-
|
|
33
|
-
For more information, see https://www.github.com/deeprails/deeprails-python-sdk#accessing-raw-response-data-eg-headers
|
|
34
|
-
"""
|
|
35
|
-
return EventsResourceWithRawResponse(self)
|
|
36
|
-
|
|
37
|
-
@cached_property
|
|
38
|
-
def with_streaming_response(self) -> EventsResourceWithStreamingResponse:
|
|
39
|
-
"""
|
|
40
|
-
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
41
|
-
|
|
42
|
-
For more information, see https://www.github.com/deeprails/deeprails-python-sdk#with_streaming_response
|
|
43
|
-
"""
|
|
44
|
-
return EventsResourceWithStreamingResponse(self)
|
|
45
|
-
|
|
46
|
-
def retrieve_event(
|
|
47
|
-
self,
|
|
48
|
-
event_id: str,
|
|
49
|
-
*,
|
|
50
|
-
workflow_id: str,
|
|
51
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
52
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
53
|
-
extra_headers: Headers | None = None,
|
|
54
|
-
extra_query: Query | None = None,
|
|
55
|
-
extra_body: Body | None = None,
|
|
56
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
57
|
-
) -> WorkflowEventResponse:
|
|
58
|
-
"""
|
|
59
|
-
Retrieve a specific event of a guardrail workflow.
|
|
60
|
-
|
|
61
|
-
Args:
|
|
62
|
-
extra_headers: Send extra headers
|
|
63
|
-
|
|
64
|
-
extra_query: Add additional query parameters to the request
|
|
65
|
-
|
|
66
|
-
extra_body: Add additional JSON properties to the request
|
|
67
|
-
|
|
68
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
69
|
-
"""
|
|
70
|
-
if not workflow_id:
|
|
71
|
-
raise ValueError(f"Expected a non-empty value for `workflow_id` but received {workflow_id!r}")
|
|
72
|
-
if not event_id:
|
|
73
|
-
raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}")
|
|
74
|
-
return self._get(
|
|
75
|
-
f"/defend/{workflow_id}/events/{event_id}",
|
|
76
|
-
options=make_request_options(
|
|
77
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
78
|
-
),
|
|
79
|
-
cast_to=WorkflowEventResponse,
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
def submit_event(
|
|
83
|
-
self,
|
|
84
|
-
workflow_id: str,
|
|
85
|
-
*,
|
|
86
|
-
model_input: event_submit_event_params.ModelInput,
|
|
87
|
-
model_output: str,
|
|
88
|
-
model_used: str,
|
|
89
|
-
nametag: str,
|
|
90
|
-
run_mode: Literal["precision_plus", "precision", "smart", "economy"],
|
|
91
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
92
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
93
|
-
extra_headers: Headers | None = None,
|
|
94
|
-
extra_query: Query | None = None,
|
|
95
|
-
extra_body: Body | None = None,
|
|
96
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
97
|
-
) -> WorkflowEventResponse:
|
|
98
|
-
"""
|
|
99
|
-
Submit a model input and output pair to a workflow for evaluation.
|
|
100
|
-
|
|
101
|
-
Args:
|
|
102
|
-
model_input: A dictionary of inputs sent to the LLM to generate output. This must contain a
|
|
103
|
-
`user_prompt` field and an optional `context` field. Additional properties are
|
|
104
|
-
allowed.
|
|
105
|
-
|
|
106
|
-
model_output: Output generated by the LLM to be evaluated.
|
|
107
|
-
|
|
108
|
-
model_used: Model ID used to generate the output, like `gpt-4o` or `o3`.
|
|
109
|
-
|
|
110
|
-
nametag: An optional, user-defined tag for the event.
|
|
111
|
-
|
|
112
|
-
run_mode: Run mode for the workflow event. The run mode allows the user to optimize for
|
|
113
|
-
speed, accuracy, and cost by determining which models are used to evaluate the
|
|
114
|
-
event. Available run modes include `precision_plus`, `precision`, `smart`, and
|
|
115
|
-
`economy`. Defaults to `smart`.
|
|
116
|
-
|
|
117
|
-
extra_headers: Send extra headers
|
|
118
|
-
|
|
119
|
-
extra_query: Add additional query parameters to the request
|
|
120
|
-
|
|
121
|
-
extra_body: Add additional JSON properties to the request
|
|
122
|
-
|
|
123
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
124
|
-
"""
|
|
125
|
-
if not workflow_id:
|
|
126
|
-
raise ValueError(f"Expected a non-empty value for `workflow_id` but received {workflow_id!r}")
|
|
127
|
-
return self._post(
|
|
128
|
-
f"/defend/{workflow_id}/events",
|
|
129
|
-
body=maybe_transform(
|
|
130
|
-
{
|
|
131
|
-
"model_input": model_input,
|
|
132
|
-
"model_output": model_output,
|
|
133
|
-
"model_used": model_used,
|
|
134
|
-
"nametag": nametag,
|
|
135
|
-
"run_mode": run_mode,
|
|
136
|
-
},
|
|
137
|
-
event_submit_event_params.EventSubmitEventParams,
|
|
138
|
-
),
|
|
139
|
-
options=make_request_options(
|
|
140
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
141
|
-
),
|
|
142
|
-
cast_to=WorkflowEventResponse,
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
class AsyncEventsResource(AsyncAPIResource):
|
|
147
|
-
@cached_property
|
|
148
|
-
def with_raw_response(self) -> AsyncEventsResourceWithRawResponse:
|
|
149
|
-
"""
|
|
150
|
-
This property can be used as a prefix for any HTTP method call to return
|
|
151
|
-
the raw response object instead of the parsed content.
|
|
152
|
-
|
|
153
|
-
For more information, see https://www.github.com/deeprails/deeprails-python-sdk#accessing-raw-response-data-eg-headers
|
|
154
|
-
"""
|
|
155
|
-
return AsyncEventsResourceWithRawResponse(self)
|
|
156
|
-
|
|
157
|
-
@cached_property
|
|
158
|
-
def with_streaming_response(self) -> AsyncEventsResourceWithStreamingResponse:
|
|
159
|
-
"""
|
|
160
|
-
An alternative to `.with_raw_response` that doesn't eagerly read the response body.
|
|
161
|
-
|
|
162
|
-
For more information, see https://www.github.com/deeprails/deeprails-python-sdk#with_streaming_response
|
|
163
|
-
"""
|
|
164
|
-
return AsyncEventsResourceWithStreamingResponse(self)
|
|
165
|
-
|
|
166
|
-
async def retrieve_event(
|
|
167
|
-
self,
|
|
168
|
-
event_id: str,
|
|
169
|
-
*,
|
|
170
|
-
workflow_id: str,
|
|
171
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
172
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
173
|
-
extra_headers: Headers | None = None,
|
|
174
|
-
extra_query: Query | None = None,
|
|
175
|
-
extra_body: Body | None = None,
|
|
176
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
177
|
-
) -> WorkflowEventResponse:
|
|
178
|
-
"""
|
|
179
|
-
Retrieve a specific event of a guardrail workflow.
|
|
180
|
-
|
|
181
|
-
Args:
|
|
182
|
-
extra_headers: Send extra headers
|
|
183
|
-
|
|
184
|
-
extra_query: Add additional query parameters to the request
|
|
185
|
-
|
|
186
|
-
extra_body: Add additional JSON properties to the request
|
|
187
|
-
|
|
188
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
189
|
-
"""
|
|
190
|
-
if not workflow_id:
|
|
191
|
-
raise ValueError(f"Expected a non-empty value for `workflow_id` but received {workflow_id!r}")
|
|
192
|
-
if not event_id:
|
|
193
|
-
raise ValueError(f"Expected a non-empty value for `event_id` but received {event_id!r}")
|
|
194
|
-
return await self._get(
|
|
195
|
-
f"/defend/{workflow_id}/events/{event_id}",
|
|
196
|
-
options=make_request_options(
|
|
197
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
198
|
-
),
|
|
199
|
-
cast_to=WorkflowEventResponse,
|
|
200
|
-
)
|
|
201
|
-
|
|
202
|
-
async def submit_event(
|
|
203
|
-
self,
|
|
204
|
-
workflow_id: str,
|
|
205
|
-
*,
|
|
206
|
-
model_input: event_submit_event_params.ModelInput,
|
|
207
|
-
model_output: str,
|
|
208
|
-
model_used: str,
|
|
209
|
-
nametag: str,
|
|
210
|
-
run_mode: Literal["precision_plus", "precision", "smart", "economy"],
|
|
211
|
-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
212
|
-
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
213
|
-
extra_headers: Headers | None = None,
|
|
214
|
-
extra_query: Query | None = None,
|
|
215
|
-
extra_body: Body | None = None,
|
|
216
|
-
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
217
|
-
) -> WorkflowEventResponse:
|
|
218
|
-
"""
|
|
219
|
-
Submit a model input and output pair to a workflow for evaluation.
|
|
220
|
-
|
|
221
|
-
Args:
|
|
222
|
-
model_input: A dictionary of inputs sent to the LLM to generate output. This must contain a
|
|
223
|
-
`user_prompt` field and an optional `context` field. Additional properties are
|
|
224
|
-
allowed.
|
|
225
|
-
|
|
226
|
-
model_output: Output generated by the LLM to be evaluated.
|
|
227
|
-
|
|
228
|
-
model_used: Model ID used to generate the output, like `gpt-4o` or `o3`.
|
|
229
|
-
|
|
230
|
-
nametag: An optional, user-defined tag for the event.
|
|
231
|
-
|
|
232
|
-
run_mode: Run mode for the workflow event. The run mode allows the user to optimize for
|
|
233
|
-
speed, accuracy, and cost by determining which models are used to evaluate the
|
|
234
|
-
event. Available run modes include `precision_plus`, `precision`, `smart`, and
|
|
235
|
-
`economy`. Defaults to `smart`.
|
|
236
|
-
|
|
237
|
-
extra_headers: Send extra headers
|
|
238
|
-
|
|
239
|
-
extra_query: Add additional query parameters to the request
|
|
240
|
-
|
|
241
|
-
extra_body: Add additional JSON properties to the request
|
|
242
|
-
|
|
243
|
-
timeout: Override the client-level default timeout for this request, in seconds
|
|
244
|
-
"""
|
|
245
|
-
if not workflow_id:
|
|
246
|
-
raise ValueError(f"Expected a non-empty value for `workflow_id` but received {workflow_id!r}")
|
|
247
|
-
return await self._post(
|
|
248
|
-
f"/defend/{workflow_id}/events",
|
|
249
|
-
body=await async_maybe_transform(
|
|
250
|
-
{
|
|
251
|
-
"model_input": model_input,
|
|
252
|
-
"model_output": model_output,
|
|
253
|
-
"model_used": model_used,
|
|
254
|
-
"nametag": nametag,
|
|
255
|
-
"run_mode": run_mode,
|
|
256
|
-
},
|
|
257
|
-
event_submit_event_params.EventSubmitEventParams,
|
|
258
|
-
),
|
|
259
|
-
options=make_request_options(
|
|
260
|
-
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
261
|
-
),
|
|
262
|
-
cast_to=WorkflowEventResponse,
|
|
263
|
-
)
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
class EventsResourceWithRawResponse:
|
|
267
|
-
def __init__(self, events: EventsResource) -> None:
|
|
268
|
-
self._events = events
|
|
269
|
-
|
|
270
|
-
self.retrieve_event = to_raw_response_wrapper(
|
|
271
|
-
events.retrieve_event,
|
|
272
|
-
)
|
|
273
|
-
self.submit_event = to_raw_response_wrapper(
|
|
274
|
-
events.submit_event,
|
|
275
|
-
)
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
class AsyncEventsResourceWithRawResponse:
|
|
279
|
-
def __init__(self, events: AsyncEventsResource) -> None:
|
|
280
|
-
self._events = events
|
|
281
|
-
|
|
282
|
-
self.retrieve_event = async_to_raw_response_wrapper(
|
|
283
|
-
events.retrieve_event,
|
|
284
|
-
)
|
|
285
|
-
self.submit_event = async_to_raw_response_wrapper(
|
|
286
|
-
events.submit_event,
|
|
287
|
-
)
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
class EventsResourceWithStreamingResponse:
|
|
291
|
-
def __init__(self, events: EventsResource) -> None:
|
|
292
|
-
self._events = events
|
|
293
|
-
|
|
294
|
-
self.retrieve_event = to_streamed_response_wrapper(
|
|
295
|
-
events.retrieve_event,
|
|
296
|
-
)
|
|
297
|
-
self.submit_event = to_streamed_response_wrapper(
|
|
298
|
-
events.submit_event,
|
|
299
|
-
)
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
class AsyncEventsResourceWithStreamingResponse:
|
|
303
|
-
def __init__(self, events: AsyncEventsResource) -> None:
|
|
304
|
-
self._events = events
|
|
305
|
-
|
|
306
|
-
self.retrieve_event = async_to_streamed_response_wrapper(
|
|
307
|
-
events.retrieve_event,
|
|
308
|
-
)
|
|
309
|
-
self.submit_event = async_to_streamed_response_wrapper(
|
|
310
|
-
events.submit_event,
|
|
311
|
-
)
|
|
@@ -1,6 +0,0 @@
|
|
|
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
|
|
File without changes
|
|
File without changes
|