deeprails 0.3.2__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.
Files changed (57) hide show
  1. deeprails/__init__.py +102 -1
  2. deeprails/_base_client.py +1995 -0
  3. deeprails/_client.py +419 -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.py +671 -0
  31. deeprails/resources/evaluate.py +334 -0
  32. deeprails/resources/monitor.py +566 -0
  33. deeprails/types/__init__.py +18 -0
  34. deeprails/types/api_response.py +50 -0
  35. deeprails/types/defend_create_workflow_params.py +56 -0
  36. deeprails/types/defend_response.py +50 -0
  37. deeprails/types/defend_submit_event_params.py +44 -0
  38. deeprails/types/defend_update_workflow_params.py +18 -0
  39. deeprails/types/evaluate_create_params.py +60 -0
  40. deeprails/types/evaluation.py +113 -0
  41. deeprails/types/monitor_create_params.py +15 -0
  42. deeprails/types/monitor_retrieve_params.py +12 -0
  43. deeprails/types/monitor_retrieve_response.py +81 -0
  44. deeprails/types/monitor_submit_event_params.py +63 -0
  45. deeprails/types/monitor_submit_event_response.py +36 -0
  46. deeprails/types/monitor_update_params.py +22 -0
  47. deeprails/types/workflow_event_response.py +33 -0
  48. deeprails-1.2.0.dist-info/METADATA +377 -0
  49. deeprails-1.2.0.dist-info/RECORD +51 -0
  50. {deeprails-0.3.2.dist-info → deeprails-1.2.0.dist-info}/WHEEL +1 -1
  51. deeprails-1.2.0.dist-info/licenses/LICENSE +201 -0
  52. deeprails/client.py +0 -285
  53. deeprails/exceptions.py +0 -10
  54. deeprails/schemas.py +0 -92
  55. deeprails-0.3.2.dist-info/METADATA +0 -235
  56. deeprails-0.3.2.dist-info/RECORD +0 -8
  57. deeprails-0.3.2.dist-info/licenses/LICENSE +0 -11
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
@@ -1,235 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: deeprails
3
- Version: 0.3.2
4
- Summary: Python SDK for interacting with the DeepRails API
5
- Project-URL: Homepage, https://deeprails.com
6
- Project-URL: Documentation, https://docs.deeprails.com
7
- Author-email: Neil Mate <support@deeprails.ai>
8
- License: MIT License
9
-
10
- Copyright (c) [2025] [DeepRails Inc.ß]
11
-
12
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
-
18
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
- License-File: LICENSE
20
- Keywords: ai,deeprails,evaluation,genai,guardrails,sdk
21
- Classifier: Intended Audience :: Developers
22
- Classifier: License :: OSI Approved :: MIT License
23
- Classifier: Operating System :: OS Independent
24
- Classifier: Programming Language :: Python :: 3
25
- Classifier: Programming Language :: Python :: 3.8
26
- Classifier: Programming Language :: Python :: 3.9
27
- Classifier: Programming Language :: Python :: 3.10
28
- Classifier: Programming Language :: Python :: 3.11
29
- Classifier: Programming Language :: Python :: 3.12
30
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
31
- Requires-Python: >=3.8
32
- Requires-Dist: httpx<0.29.0,>=0.28.1
33
- Requires-Dist: pydantic<3.0.0,>=2.11.7
34
- Description-Content-Type: text/markdown
35
-
36
- # DeepRails Python SDK
37
-
38
- Official Python SDK for interacting with the DeepRails API v2.0.
39
-
40
- DeepRails is a powerful developer tool with a comprehesive set of adaptive and accurate guardrails to protect against LLM hallucinations - deploy our Evaluate, Monitor, and Defend APIs in <15 mins for the best out-of-the-box guardrails in the market.
41
-
42
- ## Installation
43
-
44
- ```bash
45
- pip install deeprails
46
- ```
47
-
48
- ## Quick Start
49
-
50
- ```python
51
- from deeprails import DeepRails
52
-
53
- # Initialize with your API token
54
- client = DeepRails(token="YOUR_API_KEY")
55
-
56
- # Create an evaluation
57
- evaluation = client.create_evaluation(
58
- model_input={"user_prompt": "Prompt used to generate completion"},
59
- model_output="Generated output",
60
- model_used="gpt-4o-mini",
61
- guardrail_metrics=["correctness", "completeness"]
62
- )
63
- print(f"Evaluation created with ID: {evaluation.eval_id}")
64
-
65
- # Create a monitor
66
- monitor = client.create_monitor(
67
- name="Production Assistant Monitor",
68
- description="Tracking our production assistant quality"
69
- )
70
- print(f"Monitor created with ID: {monitor.monitor_id}")
71
- ```
72
-
73
- ## Features
74
-
75
- - **Simple API**: Just a few lines of code to integrate evaluation into your workflow
76
- - **Comprehensive Metrics**: Evaluate outputs on correctness, completeness, and more
77
- - **Real-time Progress**: Track evaluation progress in real-time
78
- - **Detailed Results**: Get detailed scores and rationales for each metric
79
- - **Continuous Monitoring**: Create monitors to track AI system performance over time
80
-
81
- ## Authentication
82
-
83
- All API requests require authentication using your DeepRails API key. Your API key is a sensitive credential that should be kept secure.
84
-
85
- ```python
86
- # Best practice: Load token from environment variable
87
- import os
88
- token = os.environ.get("DEEPRAILS_API_KEY")
89
- client = DeepRails(token=token)
90
- ```
91
-
92
- ## Evaluation Service
93
-
94
- ### Creating Evaluations
95
-
96
- ```python
97
- try:
98
- evaluation = client.create_evaluation(
99
- model_input={"user_prompt": "Prompt used to generate completion"},
100
- model_output="Generated output",
101
- model_used="gpt-4o-mini",
102
- guardrail_metrics=["correctness", "completeness"]
103
- )
104
- print(f"ID: {evaluation.eval_id}")
105
- print(f"Status: {evaluation.evaluation_status}")
106
- print(f"Progress: {evaluation.progress}%")
107
- except Exception as e:
108
- print(f"Error: {e}")
109
- ```
110
-
111
- #### Parameters
112
-
113
- - `model_input`: Dictionary containing the prompt and any context (must include `user_prompt`)
114
- - `model_output`: The generated output to evaluate
115
- - `model_used`: (Optional) The model that generated the output
116
- - `run_mode`: (Optional) Evaluation run mode - defaults to "smart"
117
- - `guardrail_metrics`: (Optional) List of metrics to evaluate
118
- - `nametag`: (Optional) Custom identifier for this evaluation
119
- - `webhook`: (Optional) URL to receive completion notifications
120
-
121
- ### Retrieving Evaluations
122
-
123
- ```python
124
- try:
125
- eval_id = "eval-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
126
- evaluation = client.get_evaluation(eval_id)
127
-
128
- print(f"Status: {evaluation.evaluation_status}")
129
-
130
- if evaluation.evaluation_result:
131
- print("\nResults:")
132
- for metric, result in evaluation.evaluation_result.items():
133
- score = result.get('score', 'N/A')
134
- print(f" {metric}: {score}")
135
- except Exception as e:
136
- print(f"Error: {e}")
137
- ```
138
-
139
- ## Monitor Service
140
-
141
- ### Creating Monitors
142
-
143
- ```python
144
- try:
145
- # Create a monitor
146
- monitor = client.create_monitor(
147
- name="Production Chat Assistant Monitor",
148
- description="Monitoring our production chatbot responses"
149
- )
150
-
151
- print(f"Monitor created with ID: {monitor.monitor_id}")
152
- except Exception as e:
153
- print(f"Error: {e}")
154
- ```
155
-
156
- ### Logging Monitor Events
157
-
158
- ```python
159
- try:
160
- # Add an event to the monitor
161
- event = client.create_monitor_event(
162
- monitor_id="mon-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
163
- model_input={"user_prompt": "Tell me about renewable energy"},
164
- model_output="Renewable energy comes from natural sources...",
165
- model_used="gpt-4o-mini",
166
- guardrail_metrics=["correctness", "completeness", "comprehensive_safety"]
167
- )
168
-
169
- print(f"Monitor event created with ID: {event.event_id}")
170
- print(f"Associated evaluation ID: {event.evaluation_id}")
171
- except Exception as e:
172
- print(f"Error: {e}")
173
- ```
174
-
175
- ### Retrieving Monitor Data
176
-
177
- ```python
178
- try:
179
- # Get monitor details
180
- monitor = client.get_monitor("mon-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx")
181
- print(f"Monitor name: {monitor.name}")
182
- print(f"Status: {monitor.monitor_status}")
183
-
184
- # Get monitor events
185
- events = client.get_monitor_events(
186
- monitor_id="mon-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
187
- limit=10
188
- )
189
-
190
- for event in events:
191
- print(f"Event ID: {event.event_id}")
192
- print(f"Evaluation ID: {event.evaluation_id}")
193
-
194
- # List all monitors with filtering
195
- monitors = client.get_monitors(
196
- limit=5,
197
- monitor_status=["active"],
198
- sort_by="created_at",
199
- sort_order="desc"
200
- )
201
-
202
- print(f"Total monitors: {monitors.pagination.total_count}")
203
- for m in monitors.monitors:
204
- print(f"{m.name}: {m.event_count} events")
205
- except Exception as e:
206
- print(f"Error: {e}")
207
- ```
208
-
209
- ## Available Metrics
210
-
211
- - `correctness`: Measures factual accuracy by evaluating whether each claim in the output is true and verifiable.
212
- - `completeness`: Assesses whether the response addresses all necessary parts of the prompt with sufficient detail and relevance.
213
- - `instruction_adherence`: Checks whether the AI followed the explicit instructions in the prompt and system directives.
214
- - `context_adherence`: Determines whether each factual claim is directly supported by the provided context.
215
- - `ground_truth_adherence`: Measures how closely the output matches a known correct answer (gold standard).
216
- - `comprehensive_safety`: Detects and categorizes safety violations across areas like PII, CBRN, hate speech, self-harm, and more.
217
-
218
- ## Error Handling
219
-
220
- The SDK throws `DeepRailsAPIError` for API-related errors, with status code and detailed message.
221
-
222
- ```python
223
- from deeprails import DeepRailsAPIError
224
-
225
- try:
226
- # SDK operations
227
- except DeepRailsAPIError as e:
228
- print(f"API Error: {e.status_code} - {e.error_detail}")
229
- except Exception as e:
230
- print(f"Unexpected error: {e}")
231
- ```
232
-
233
- ## Support
234
-
235
- For questions or support, please contact support@deeprails.ai.
@@ -1,8 +0,0 @@
1
- deeprails/__init__.py,sha256=7ccTz1heYcCd3DIH3wmHc67FD6CUzM8_J4WmDeq0RZ0,29
2
- deeprails/client.py,sha256=CbwE0StrrCeuvDC9NSmt_iDoUIuTn9ODd3sPMVbruiI,10406
3
- deeprails/exceptions.py,sha256=ipwFq4lROv7XpcBC5h9cGqPf6f68zeOMEyKPVy7H0co,405
4
- deeprails/schemas.py,sha256=XqBUFNEW4nwxm53YIUWVk4fEPsDGC6gzzXGL9lPuRAU,2870
5
- deeprails-0.3.2.dist-info/METADATA,sha256=fycma2juTg3YVd54dkZYqnTExHHUWx1_Xtrj_zFX_h4,8495
6
- deeprails-0.3.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
- deeprails-0.3.2.dist-info/licenses/LICENSE,sha256=GsV7lN6fihCcDgkJbfs0rq1q9d6IyB0TFQ8HLKUpSXM,1077
8
- deeprails-0.3.2.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) [2025] [DeepRails Inc.ß]
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
-
7
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
10
-
11
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.