deeprails 0.1.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.
- deeprails/__init__.py +0 -0
- deeprails/client.py +31 -0
- deeprails/evaluate.py +46 -0
- deeprails/monitor.py +50 -0
- deeprails-0.1.0.dist-info/LICENSE +11 -0
- deeprails-0.1.0.dist-info/METADATA +86 -0
- deeprails-0.1.0.dist-info/RECORD +9 -0
- deeprails-0.1.0.dist-info/WHEEL +5 -0
- deeprails-0.1.0.dist-info/top_level.txt +1 -0
deeprails/__init__.py
ADDED
|
File without changes
|
deeprails/client.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from typing import Dict, Any
|
|
3
|
+
|
|
4
|
+
from .evaluate import EvaluateClient
|
|
5
|
+
from .monitor import MonitorClient
|
|
6
|
+
|
|
7
|
+
class DeepRails:
|
|
8
|
+
"""
|
|
9
|
+
Main entry point for the deeprails client.
|
|
10
|
+
|
|
11
|
+
Usage:
|
|
12
|
+
from deeprails import DeepRails
|
|
13
|
+
|
|
14
|
+
client = DeepRails(token="YOUR_TOKEN")
|
|
15
|
+
resp = client.evaluate.create({...})
|
|
16
|
+
"""
|
|
17
|
+
def __init__(self, token: str, base_url: str = "https://deeprails.ai"):
|
|
18
|
+
"""
|
|
19
|
+
:param token: Bearer token for authentication.
|
|
20
|
+
:param base_url: Base URL for the DeepRails API.
|
|
21
|
+
"""
|
|
22
|
+
self.token = token
|
|
23
|
+
self.base_url = base_url.rstrip("/")
|
|
24
|
+
# Common headers for all requests
|
|
25
|
+
self.headers = {
|
|
26
|
+
"Content-Type": "application/json",
|
|
27
|
+
"Authorization": f"Bearer {self.token}"
|
|
28
|
+
}
|
|
29
|
+
# Create client objects
|
|
30
|
+
self.evaluate = EvaluateClient(self.base_url, self.headers)
|
|
31
|
+
self.monitor = MonitorClient(self.base_url, self.headers)
|
deeprails/evaluate.py
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from typing import Dict, Any
|
|
3
|
+
|
|
4
|
+
class EvaluateClient:
|
|
5
|
+
"""
|
|
6
|
+
Client for the Evaluate endpoints:
|
|
7
|
+
- POST / (create a new evaluation)
|
|
8
|
+
- GET /{eval_id} (fetch an existing evaluation)
|
|
9
|
+
"""
|
|
10
|
+
def __init__(self, base_url: str, headers: Dict[str, str]):
|
|
11
|
+
self.base_url = f"{base_url}/evaluate"
|
|
12
|
+
self.headers = headers
|
|
13
|
+
|
|
14
|
+
def create(self, evaluation_data: Dict[str, Any]) -> Dict[str, Any]:
|
|
15
|
+
"""
|
|
16
|
+
Create a new evaluation by POSTing to /evaluate.
|
|
17
|
+
|
|
18
|
+
:param evaluation_data: Dict matching the EvaluateCreate model:
|
|
19
|
+
{
|
|
20
|
+
"model_input": {...},
|
|
21
|
+
"model_output": "...",
|
|
22
|
+
"type": "...",
|
|
23
|
+
"guardrails_metrics": [...],
|
|
24
|
+
"score_format": "...",
|
|
25
|
+
"webhook": "..."
|
|
26
|
+
}
|
|
27
|
+
:return: The JSON response from the API as a Python dict
|
|
28
|
+
matching EvaluationResponse.
|
|
29
|
+
"""
|
|
30
|
+
url = self.base_url # e.g. https://deeprails.ai/evaluate
|
|
31
|
+
response = requests.post(url, json=evaluation_data, headers=self.headers)
|
|
32
|
+
response.raise_for_status()
|
|
33
|
+
return response.json()
|
|
34
|
+
|
|
35
|
+
def fetch(self, eval_id: str) -> Dict[str, Any]:
|
|
36
|
+
"""
|
|
37
|
+
Fetch an existing evaluation by GETting /evaluate/{eval_id}.
|
|
38
|
+
|
|
39
|
+
:param eval_id: The ID of the evaluation to retrieve
|
|
40
|
+
:return: The JSON response as a Python dict
|
|
41
|
+
matching EvaluationResponse.
|
|
42
|
+
"""
|
|
43
|
+
url = f"{self.base_url}/{eval_id}"
|
|
44
|
+
response = requests.get(url, headers=self.headers)
|
|
45
|
+
response.raise_for_status()
|
|
46
|
+
return response.json()
|
deeprails/monitor.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
from typing import Dict, Any
|
|
3
|
+
|
|
4
|
+
class MonitorClient:
|
|
5
|
+
"""
|
|
6
|
+
Client for the Monitor endpoints:
|
|
7
|
+
- POST / (create a new monitor)
|
|
8
|
+
- POST /{monitor_id}/event (log an event)
|
|
9
|
+
"""
|
|
10
|
+
def __init__(self, base_url: str, headers: Dict[str, str]):
|
|
11
|
+
self.base_url = f"{base_url}/monitor"
|
|
12
|
+
self.headers = headers
|
|
13
|
+
|
|
14
|
+
def create(self, monitor_data: Dict[str, Any]) -> Dict[str, Any]:
|
|
15
|
+
"""
|
|
16
|
+
Create a new monitor.
|
|
17
|
+
|
|
18
|
+
:param monitor_data: Dict matching the MonitorCreate model:
|
|
19
|
+
{
|
|
20
|
+
"name": "...",
|
|
21
|
+
"description": "...",
|
|
22
|
+
"metrics": [...]
|
|
23
|
+
}
|
|
24
|
+
:return: Dictionary with e.g. {"monitor_id": "..."} from the API.
|
|
25
|
+
"""
|
|
26
|
+
url = self.base_url # e.g. https://deeprails.ai/monitor
|
|
27
|
+
response = requests.post(url, json=monitor_data, headers=self.headers)
|
|
28
|
+
response.raise_for_status()
|
|
29
|
+
return response.json()
|
|
30
|
+
|
|
31
|
+
def log(self, monitor_id: str, event_data: Dict[str, Any]) -> Dict[str, Any]:
|
|
32
|
+
"""
|
|
33
|
+
Log an event under a specific monitor.
|
|
34
|
+
|
|
35
|
+
:param monitor_id: ID of the monitor to which we log the event
|
|
36
|
+
:param event_data: Dict matching MonitorEventCreate:
|
|
37
|
+
{
|
|
38
|
+
"model_input": {...},
|
|
39
|
+
"model_output": {...},
|
|
40
|
+
"temperature": 0.7,
|
|
41
|
+
"top_p": 1.0,
|
|
42
|
+
"model": "gpt-3.5-turbo",
|
|
43
|
+
...
|
|
44
|
+
}
|
|
45
|
+
:return: Dictionary with e.g. {"event_id": "..."} from the API.
|
|
46
|
+
"""
|
|
47
|
+
url = f"{self.base_url}/{monitor_id}/event"
|
|
48
|
+
response = requests.post(url, json=event_data, headers=self.headers)
|
|
49
|
+
response.raise_for_status()
|
|
50
|
+
return response.json()
|
|
@@ -0,0 +1,11 @@
|
|
|
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.
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: deeprails
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python client library for deeprails.ai
|
|
5
|
+
Home-page: https://github.com/yourusername/deeprails
|
|
6
|
+
Author: Your Name or Organization
|
|
7
|
+
Author-email: your.email@example.com
|
|
8
|
+
License: UNKNOWN
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.7
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: requests (>=2.0.0)
|
|
17
|
+
|
|
18
|
+
# DeepRails
|
|
19
|
+
|
|
20
|
+
A Python client library for interacting with the [DeepRails.ai](https://deeprails.ai) API. This package exposes high-level methods for creating and fetching evaluations, as well as creating monitors and logging monitor events.
|
|
21
|
+
|
|
22
|
+
## Features
|
|
23
|
+
|
|
24
|
+
- **Evaluation**:
|
|
25
|
+
- `client.evaluate.create(data)` – Create an evaluation
|
|
26
|
+
- `client.evaluate.fetch(eval_id)` – Retrieve the status and results of an evaluation
|
|
27
|
+
|
|
28
|
+
- **Monitor**:
|
|
29
|
+
- `client.monitor.create(data)` – Create a monitor
|
|
30
|
+
- `client.monitor.log(monitor_id, data)` – Log an event under a monitor
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
Install via [PyPI](https://pypi.org/) using:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install deeprails
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
```python
|
|
42
|
+
from deeprails import DeepRails
|
|
43
|
+
|
|
44
|
+
# Initialize the client (replace "YOUR_TOKEN" with a valid token)
|
|
45
|
+
client = DeepRails(token="YOUR_TOKEN")
|
|
46
|
+
|
|
47
|
+
# 1) Create an evaluation
|
|
48
|
+
eval_request_data = {
|
|
49
|
+
"model_input": {"user_prompt": "Write a poem about winter"},
|
|
50
|
+
"model_output": "A frosty greeting on a snowy morn...",
|
|
51
|
+
"type": "text",
|
|
52
|
+
"guardrails_metrics": ["correctness", "completeness"],
|
|
53
|
+
"score_format": "continuous",
|
|
54
|
+
"webhook": None
|
|
55
|
+
}
|
|
56
|
+
eval_response = client.evaluate.create(eval_request_data)
|
|
57
|
+
print("Evaluation created:", eval_response)
|
|
58
|
+
|
|
59
|
+
# 2) Fetch the evaluation by ID
|
|
60
|
+
evaluation = client.evaluate.fetch(eval_response["eval_id"])
|
|
61
|
+
print("Fetched evaluation:", evaluation)
|
|
62
|
+
|
|
63
|
+
# 3) Create a new monitor
|
|
64
|
+
monitor_data = {
|
|
65
|
+
"name": "My Example Monitor",
|
|
66
|
+
"description": "Track LLM usage in production",
|
|
67
|
+
"metrics": ["correctness", "completeness"]
|
|
68
|
+
}
|
|
69
|
+
monitor_resp = client.monitor.create(monitor_data)
|
|
70
|
+
monitor_id = monitor_resp["monitor_id"]
|
|
71
|
+
print("Monitor created:", monitor_resp)
|
|
72
|
+
|
|
73
|
+
# 4) Log an event under that monitor
|
|
74
|
+
event_data = {
|
|
75
|
+
"model_input": {"user_prompt": "Tell me a joke"},
|
|
76
|
+
"model_output": {"response": "Why did the chicken cross the road..."},
|
|
77
|
+
"temperature": 0.7,
|
|
78
|
+
"top_p": 1.0,
|
|
79
|
+
"model": "gpt-3.5-turbo"
|
|
80
|
+
}
|
|
81
|
+
event_resp = client.monitor.log(monitor_id, event_data)
|
|
82
|
+
print("Monitor event logged:", event_resp)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
deeprails/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
deeprails/client.py,sha256=28vSTSp2tWzFLJq4racWW4lXMXOyF3W9hEvROhZd5VU,983
|
|
3
|
+
deeprails/evaluate.py,sha256=HJ3QtGiCho169r8dx1LXV6U7xjbreTr1X2BjDEfFwuw,1647
|
|
4
|
+
deeprails/monitor.py,sha256=XYtl5TdNqRHtrUetSYHxAOJNisFE_uLmbFSa__q08kA,1743
|
|
5
|
+
deeprails-0.1.0.dist-info/LICENSE,sha256=GsV7lN6fihCcDgkJbfs0rq1q9d6IyB0TFQ8HLKUpSXM,1077
|
|
6
|
+
deeprails-0.1.0.dist-info/METADATA,sha256=kmaiXXtnBuZQhT_tV0vKJH1P3Z3RVU3Npk-dRkg4cj8,2578
|
|
7
|
+
deeprails-0.1.0.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
|
8
|
+
deeprails-0.1.0.dist-info/top_level.txt,sha256=8-3gictPOXqg2k5S_yW66DdO8EqZ-YFab0LNarWUv4Q,10
|
|
9
|
+
deeprails-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
deeprails
|