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,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2025 Deeprails
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
deeprails/client.py DELETED
@@ -1,285 +0,0 @@
1
- import httpx
2
- from typing import List, Optional, Dict, Any
3
-
4
- from .schemas import EvaluationResponse
5
- from .exceptions import DeepRailsAPIError
6
-
7
- class DeepRails:
8
- """
9
- Python SDK client for the DeepRails API.
10
- """
11
-
12
- def __init__(self, token: str, base_url: str = "https://api.deeprails.com"):
13
- """
14
- Initializes the DeepRails client.
15
-
16
- Args:
17
- token: Your DeepRails API key (starts with 'sk_').
18
- base_url: The base URL of the DeepRails API.
19
- """
20
- if not token:
21
- raise ValueError("A valid DeepRails API token is required.")
22
-
23
- self._base_url = base_url
24
- self._headers = {
25
- "Authorization": f"Bearer {token}",
26
- "Content-Type": "application/json",
27
- "User-Agent": "deeprails-python-sdk/0.3.2"
28
- }
29
- self._client = httpx.Client(base_url=self._base_url, headers=self._headers, timeout=30.0)
30
-
31
-
32
- def _request(self, method: str, endpoint: str, **kwargs) -> httpx.Response:
33
- """Helper method to make requests and handle API errors."""
34
- try:
35
- response = self._client.request(method, endpoint, **kwargs)
36
- response.raise_for_status()
37
- return response
38
- except httpx.HTTPStatusError as e:
39
- error_detail = "No detail provided."
40
- try:
41
- error_detail = e.response.json().get("detail", error_detail)
42
- except Exception:
43
- error_detail = e.response.text
44
- raise DeepRailsAPIError(status_code=e.response.status_code, error_detail=error_detail) from e
45
- except httpx.RequestError as e:
46
- raise DeepRailsAPIError(status_code=500, error_detail=f"Request failed: {e}") from e
47
-
48
-
49
- def create_evaluation(
50
- self,
51
- *,
52
- model_input: Dict[str, Any],
53
- model_output: str,
54
- model_used: Optional[str] = None,
55
- run_mode: Optional[str] = "smart", # Set default to "smart"
56
- guardrail_metrics: Optional[List[str]] = None,
57
- nametag: Optional[str] = None,
58
- webhook: Optional[str] = None
59
- ) -> EvaluationResponse:
60
- """
61
- Creates a new evaluation and immediately processes it.
62
-
63
- Args:
64
- model_input: A dictionary containing the inputs for the model.
65
- Must contain a "user_prompt" key.
66
- model_output: The response generated by the model you are evaluating.
67
- model_used: The name or identifier of the model being evaluated.
68
- run_mode: The evaluation mode (e.g., "smart", "dev").
69
- guardrail_metrics: A list of metrics to evaluate.
70
- nametag: A user-defined name or tag for the evaluation.
71
- webhook: A URL to send a POST request to upon evaluation completion.
72
-
73
- Returns:
74
- An EvaluationResponse object with the details of the created evaluation.
75
- """
76
- if "user_prompt" not in model_input:
77
- raise ValueError("`model_input` must contain a 'user_prompt' key.")
78
-
79
- payload = {
80
- "model_input": model_input,
81
- "model_output": model_output,
82
- "model_used": model_used,
83
- "run_mode": run_mode,
84
- "guardrail_metrics": guardrail_metrics,
85
- "nametag": nametag,
86
- "webhook": webhook,
87
- }
88
- json_payload = {k: v for k, v in payload.items() if v is not None}
89
-
90
- response = self._request("POST", "/evaluate", json=json_payload)
91
- return EvaluationResponse.parse_obj(response.json())
92
-
93
-
94
- def get_evaluation(self, eval_id: str) -> EvaluationResponse:
95
- """
96
- Retrieves the status and results of a specific evaluation.
97
-
98
- Args:
99
- eval_id: The unique identifier of the evaluation.
100
-
101
- Returns:
102
- An EvaluationResponse object with the full, up-to-date details of the evaluation.
103
- """
104
- response = self._request("GET", f"/evaluate/{eval_id}")
105
- return EvaluationResponse.parse_obj(response.json())
106
-
107
-
108
- def create_monitor(
109
- self,
110
- *,
111
- name: str,
112
- description: Optional[str] = None
113
- ) -> MonitorResponse:
114
- """
115
- Creates a new monitor for tracking AI responses.
116
-
117
- Args:
118
- name: A name for the monitor.
119
- description: Optional description of the monitor's purpose.
120
-
121
- Returns:
122
- A MonitorResponse object with the details of the created monitor.
123
- """
124
- payload = {
125
- "name": name,
126
- "description": description
127
- }
128
-
129
- # Remove None values
130
- json_payload = {k: v for k, v in payload.items() if v is not None}
131
-
132
- response = self._request("POST", "/monitor", json=json_payload)
133
- response_json = response.json()
134
-
135
- # Handle DeepRails API response structure
136
- if "data" in response_json:
137
- return MonitorResponse.parse_obj(response_json["data"])
138
- else:
139
- return MonitorResponse.parse_obj(response_json)
140
-
141
- def get_monitor(self, monitor_id: str) -> MonitorResponse:
142
- """
143
- Get details of a specific monitor.
144
-
145
- Args:
146
- monitor_id: The ID of the monitor to retrieve.
147
-
148
- Returns:
149
- A MonitorResponse object with the monitor details.
150
- """
151
- response = self._request("GET", f"/monitor/{monitor_id}")
152
- response_json = response.json()
153
-
154
- # Handle DeepRails API response structure
155
- if "data" in response_json:
156
- return MonitorResponse.parse_obj(response_json["data"])
157
- else:
158
- return MonitorResponse.parse_obj(response_json)
159
-
160
- def create_monitor_event(
161
- self,
162
- *,
163
- monitor_id: str,
164
- model_input: Dict[str, Any],
165
- model_output: str,
166
- guardrail_metrics: List[str],
167
- model_used: Optional[str] = None,
168
- run_mode: Optional[str] = None,
169
- nametag: Optional[str] = None,
170
- webhook: Optional[str] = None
171
- ) -> MonitorEventResponse:
172
- """
173
- Creates a new event for a monitor.
174
-
175
- Args:
176
- monitor_id: The ID of the monitor to create an event for.
177
- model_input: A dictionary containing the inputs for the model.
178
- model_output: The response generated by the model you are evaluating.
179
- guardrail_metrics: A list of metrics to evaluate.
180
- model_used: The name or identifier of the model being evaluated.
181
- run_mode: The evaluation mode (e.g., "smart", "dev").
182
- nametag: A user-defined name or tag for the event.
183
- webhook: A URL to send a POST request to upon evaluation completion.
184
-
185
- Returns:
186
- A MonitorEventResponse object with the details of the created event.
187
- """
188
- payload = {
189
- "model_input": model_input,
190
- "model_output": model_output,
191
- "model_used": model_used,
192
- "run_mode": run_mode,
193
- "guardrail_metrics": guardrail_metrics,
194
- "nametag": nametag,
195
- "webhook": webhook,
196
- }
197
-
198
- # Remove None values
199
- json_payload = {k: v for k, v in payload.items() if v is not None}
200
-
201
- response = self._request("POST", f"/monitor/{monitor_id}/events", json=json_payload)
202
- response_json = response.json()
203
-
204
- # Handle DeepRails API response structure
205
- if "data" in response_json:
206
- return MonitorEventResponse.parse_obj(response_json["data"])
207
- else:
208
- return MonitorEventResponse.parse_obj(response_json)
209
-
210
- def get_monitor_events(
211
- self,
212
- monitor_id: str,
213
- limit: int = 10,
214
- offset: int = 0
215
- ) -> List[MonitorEventResponse]:
216
- """
217
- Retrieves events for a specific monitor.
218
-
219
- Args:
220
- monitor_id: The ID of the monitor to get events for.
221
- limit: Maximum number of events to return (default: 10).
222
- offset: Offset for pagination (default: 0).
223
-
224
- Returns:
225
- A list of MonitorEventResponse objects with details of the monitor events.
226
- """
227
- params = {
228
- "limit": limit,
229
- "offset": offset
230
- }
231
-
232
- response = self._request("GET", f"/monitor/{monitor_id}/events", params=params)
233
- response_json = response.json()
234
-
235
- # Handle DeepRails API response structure
236
- if "data" in response_json and isinstance(response_json["data"], list):
237
- return [MonitorEventResponse.parse_obj(event) for event in response_json["data"]]
238
- else:
239
- # Fallback if the response structure is unexpected
240
- return []
241
-
242
- def get_monitors(
243
- self,
244
- *,
245
- page: int = 1,
246
- limit: int = 20,
247
- search: Optional[List[str]] = None,
248
- monitor_status: Optional[List[str]] = None,
249
- date_from: Optional[str] = None,
250
- date_to: Optional[str] = None,
251
- sort_by: str = "created_at",
252
- sort_order: str = "desc"
253
- ) -> MonitorListResponse:
254
- """
255
- Get a paginated list of monitors with optional filtering.
256
-
257
- Args:
258
- page: Page number for pagination (default: 1)
259
- limit: Number of items per page (default: 20, max: 100)
260
- search: Optional list of free-text search terms
261
- monitor_status: Optional list of monitor statuses ("active", "inactive", "all")
262
- date_from: Optional filter for monitors from this date (ISO format)
263
- date_to: Optional filter for monitors to this date (ISO format)
264
- sort_by: Field to sort by (default: "created_at")
265
- sort_order: Sort order (default: "desc")
266
-
267
- Returns:
268
- A MonitorListResponse object containing monitors, pagination info, and applied filters.
269
- """
270
- params = {
271
- "page": page,
272
- "limit": limit,
273
- "sort_by": sort_by,
274
- "sort_order": sort_order,
275
- "search": search,
276
- "monitor_status": monitor_status,
277
- "date_from": date_from,
278
- "date_to": date_to
279
- }
280
-
281
- # Remove None values
282
- params = {k: v for k, v in params.items() if v is not None}
283
-
284
- response = self._request("GET", "/monitor", params=params)
285
- return MonitorListResponse.parse_obj(response.json())
deeprails/exceptions.py DELETED
@@ -1,10 +0,0 @@
1
- class DeepRailsError(Exception):
2
- """Base exception class for the DeepRails SDK."""
3
- pass
4
-
5
- class DeepRailsAPIError(DeepRailsError):
6
- """Raised when the DeepRails API returns an error."""
7
- def __init__(self, status_code: int, error_detail: str):
8
- self.status_code = status_code
9
- self.error_detail = error_detail
10
- super().__init__(f"API Error {status_code}: {error_detail}")
deeprails/schemas.py DELETED
@@ -1,92 +0,0 @@
1
- from typing import List, Optional, Dict, Any
2
- from pydantic import BaseModel, Field
3
- from datetime import datetime
4
-
5
-
6
- class EvaluationResponse(BaseModel):
7
- """Represents the response for an evaluation from the DeepRails API."""
8
- eval_id: str
9
- evaluation_status: str
10
- guardrail_metrics: Optional[List[str]] = None
11
- model_used: Optional[str] = None
12
- run_mode: Optional[str] = None
13
- model_input: Optional[Dict[str, Any]] = None
14
- model_output: Optional[str] = None
15
- estimated_cost: Optional[float] = None
16
- input_tokens: Optional[int] = None
17
- output_tokens: Optional[int] = None
18
- nametag: Optional[str] = None
19
- progress: Optional[int] = Field(None, ge=0, le=100)
20
- start_timestamp: Optional[datetime] = None
21
- completion_timestamp: Optional[datetime] = None
22
- error_message: Optional[str] = None
23
- error_timestamp: Optional[datetime] = None
24
- evaluation_result: Optional[Dict[str, Any]] = None
25
- evaluation_total_cost: Optional[float] = None
26
- created_at: Optional[datetime] = None
27
- modified_at: Optional[datetime] = None
28
-
29
- class Config:
30
- extra = 'ignore'
31
-
32
- class MonitorResponse(BaseModel):
33
- """Represents a monitor from the DeepRails API."""
34
- monitor_id: str
35
- user_id: str
36
- name: str
37
- description: Optional[str] = None
38
- monitor_status: str
39
- created_at: str
40
- updated_at: str
41
-
42
- class Config:
43
- extra = 'ignore'
44
-
45
- class MonitorEventCreate(BaseModel):
46
- """Model for creating a new monitor event."""
47
- model_input: Dict[str, Any]
48
- model_output: str
49
- model_used: Optional[str] = None
50
- run_mode: Optional[str] = None
51
- guardrail_metrics: List[str]
52
- nametag: Optional[str] = None
53
- webhook: Optional[str] = None
54
-
55
- class MonitorEventResponse(BaseModel):
56
- """Response model for a monitor event."""
57
- event_id: str
58
- monitor_id: str
59
- evaluation_id: str
60
- created_at: str
61
-
62
- class Config:
63
- extra = 'ignore'
64
-
65
- class PaginationInfo(BaseModel):
66
- """Pagination information for list responses."""
67
- page: int
68
- limit: int
69
- total_pages: int
70
- total_count: int
71
- has_next: bool
72
- has_previous: bool
73
-
74
- class MonitorFiltersApplied(BaseModel):
75
- """Information about which filters were applied to the monitor query."""
76
- search: Optional[List[str]] = None
77
- status: Optional[List[str]] = None
78
- date_from: Optional[str] = None
79
- date_to: Optional[str] = None
80
- sort_by: Optional[str] = None
81
- sort_order: Optional[str] = None
82
-
83
- class MonitorWithEventCountResponse(MonitorResponse):
84
- """Monitor response with event count information."""
85
- event_count: int
86
- latest_event_modified_at: Optional[str] = None
87
-
88
- class MonitorListResponse(BaseModel):
89
- """Response model for a paginated list of monitors."""
90
- monitors: List[MonitorWithEventCountResponse]
91
- pagination: PaginationInfo
92
- filters_applied: MonitorFiltersApplied