hivetrace 1.3.6__tar.gz → 1.3.8__tar.gz
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.
- {hivetrace-1.3.6 → hivetrace-1.3.8}/PKG-INFO +79 -50
- {hivetrace-1.3.6 → hivetrace-1.3.8}/README.md +78 -49
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace.egg-info/PKG-INFO +79 -50
- {hivetrace-1.3.6 → hivetrace-1.3.8}/setup.py +1 -1
- {hivetrace-1.3.6 → hivetrace-1.3.8}/LICENSE +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/__init__.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/__init__.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/base_adapter.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/crewai/__init__.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/crewai/adapter.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/crewai/decorators.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/crewai/monitored_agent.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/crewai/monitored_crew.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/crewai/tool_wrapper.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/langchain/__init__.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/langchain/adapter.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/langchain/api.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/langchain/behavior_tracker.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/langchain/callback.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/langchain/decorators.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/langchain/models.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/openai_agents/__init__.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/openai_agents/adapter.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/openai_agents/models.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/openai_agents/tracing.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/utils/__init__.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/adapters/utils/logging.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/client/__init__.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/client/async_client.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/client/base.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/client/sync_client.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/errors/__init__.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/errors/api.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/errors/base.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/errors/network.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/errors/validation.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/handlers/__init__.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/handlers/error_handler.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/handlers/response_builder.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/models/__init__.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/models/requests.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/models/responses.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/utils/__init__.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/utils/error_helpers.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace/utils/uuid_generator.py +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace.egg-info/SOURCES.txt +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace.egg-info/dependency_links.txt +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace.egg-info/requires.txt +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/hivetrace.egg-info/top_level.txt +0 -0
- {hivetrace-1.3.6 → hivetrace-1.3.8}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hivetrace
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.8
|
|
4
4
|
Summary: Hivetrace SDK for monitoring LLM applications
|
|
5
5
|
Home-page: http://hivetrace.ai
|
|
6
6
|
Author: Raft
|
|
@@ -20,45 +20,49 @@ License-File: LICENSE
|
|
|
20
20
|
|
|
21
21
|
## Overview
|
|
22
22
|
|
|
23
|
-
Hivetrace SDK
|
|
23
|
+
The Hivetrace SDK lets you integrate with the Hivetrace service to monitor user prompts and LLM responses. It supports both synchronous and asynchronous workflows and can be configured via environment variables.
|
|
24
|
+
|
|
25
|
+
---
|
|
24
26
|
|
|
25
27
|
## Installation
|
|
26
28
|
|
|
27
|
-
Install
|
|
29
|
+
Install from PyPI:
|
|
28
30
|
|
|
29
31
|
```bash
|
|
30
32
|
pip install hivetrace[base]
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
34
38
|
|
|
35
39
|
```python
|
|
36
40
|
from hivetrace import SyncHivetraceSDK, AsyncHivetraceSDK
|
|
37
41
|
```
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
You can use either the synchronous client (`SyncHivetraceSDK`) or the asynchronous client (`AsyncHivetraceSDK`). Choose the one that fits your runtime.
|
|
40
44
|
|
|
41
|
-
|
|
45
|
+
---
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
## Synchronous Client
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
### Initialize (Sync)
|
|
46
50
|
|
|
47
51
|
```python
|
|
48
|
-
#
|
|
52
|
+
# The sync client reads configuration from environment variables or accepts an explicit config
|
|
49
53
|
client = SyncHivetraceSDK()
|
|
50
54
|
```
|
|
51
55
|
|
|
52
|
-
|
|
56
|
+
### Send a user prompt (input)
|
|
53
57
|
|
|
54
58
|
```python
|
|
55
59
|
response = client.input(
|
|
56
|
-
application_id="your-application-id", #
|
|
60
|
+
application_id="your-application-id", # Obtained after registering the application in the UI
|
|
57
61
|
message="User prompt here",
|
|
58
62
|
)
|
|
59
63
|
```
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
### Send an LLM response (output)
|
|
62
66
|
|
|
63
67
|
```python
|
|
64
68
|
response = client.output(
|
|
@@ -67,16 +71,18 @@ response = client.output(
|
|
|
67
71
|
)
|
|
68
72
|
```
|
|
69
73
|
|
|
70
|
-
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Asynchronous Client
|
|
71
77
|
|
|
72
|
-
|
|
78
|
+
### Initialize (Async)
|
|
73
79
|
|
|
74
80
|
```python
|
|
75
|
-
#
|
|
81
|
+
# The async client can be used as a context manager
|
|
76
82
|
client = AsyncHivetraceSDK()
|
|
77
83
|
```
|
|
78
84
|
|
|
79
|
-
|
|
85
|
+
### Send a user prompt (input)
|
|
80
86
|
|
|
81
87
|
```python
|
|
82
88
|
response = await client.input(
|
|
@@ -85,7 +91,7 @@ response = await client.input(
|
|
|
85
91
|
)
|
|
86
92
|
```
|
|
87
93
|
|
|
88
|
-
|
|
94
|
+
### Send an LLM response (output)
|
|
89
95
|
|
|
90
96
|
```python
|
|
91
97
|
response = await client.output(
|
|
@@ -94,11 +100,13 @@ response = await client.output(
|
|
|
94
100
|
)
|
|
95
101
|
```
|
|
96
102
|
|
|
103
|
+
---
|
|
104
|
+
|
|
97
105
|
## Example with Additional Parameters
|
|
98
106
|
|
|
99
107
|
```python
|
|
100
108
|
response = client.input(
|
|
101
|
-
application_id="your-application-id",
|
|
109
|
+
application_id="your-application-id",
|
|
102
110
|
message="User prompt here",
|
|
103
111
|
additional_parameters={
|
|
104
112
|
"session_id": "your-session-id",
|
|
@@ -112,7 +120,9 @@ response = client.input(
|
|
|
112
120
|
)
|
|
113
121
|
```
|
|
114
122
|
|
|
115
|
-
> **Note:** `session_id`, `user_id`, and
|
|
123
|
+
> **Note:** `session_id`, `user_id`, and all agent IDs must be valid UUIDs.
|
|
124
|
+
|
|
125
|
+
---
|
|
116
126
|
|
|
117
127
|
## API
|
|
118
128
|
|
|
@@ -126,27 +136,29 @@ def input(application_id: str, message: str, additional_parameters: dict | None
|
|
|
126
136
|
async def input(application_id: str, message: str, additional_parameters: dict | None = None) -> dict: ...
|
|
127
137
|
```
|
|
128
138
|
|
|
129
|
-
Sends a user prompt to Hivetrace.
|
|
139
|
+
Sends a **user prompt** to Hivetrace.
|
|
130
140
|
|
|
131
|
-
* `application_id
|
|
132
|
-
* `message
|
|
133
|
-
* `additional_parameters
|
|
141
|
+
* `application_id` — Application identifier (must be a valid UUID, created in the UI)
|
|
142
|
+
* `message` — The user prompt
|
|
143
|
+
* `additional_parameters` — Optional dictionary with extra context (session, user, agents, etc.)
|
|
134
144
|
|
|
135
|
-
**Response
|
|
145
|
+
**Response example:**
|
|
136
146
|
|
|
137
147
|
```json
|
|
138
148
|
{
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
"status": "processed",
|
|
150
|
+
"monitoring_result": {
|
|
151
|
+
"is_toxic": false,
|
|
152
|
+
"type_of_violation": "benign",
|
|
153
|
+
"token_count": 9,
|
|
154
|
+
"token_usage_warning": false,
|
|
155
|
+
"token_usage_unbounded": false
|
|
156
|
+
}
|
|
147
157
|
}
|
|
148
158
|
```
|
|
149
159
|
|
|
160
|
+
---
|
|
161
|
+
|
|
150
162
|
### `output`
|
|
151
163
|
|
|
152
164
|
```python
|
|
@@ -157,39 +169,41 @@ def output(application_id: str, message: str, additional_parameters: dict | None
|
|
|
157
169
|
async def output(application_id: str, message: str, additional_parameters: dict | None = None) -> dict: ...
|
|
158
170
|
```
|
|
159
171
|
|
|
160
|
-
Sends an LLM response to Hivetrace.
|
|
172
|
+
Sends an **LLM response** to Hivetrace.
|
|
161
173
|
|
|
162
|
-
* `application_id
|
|
163
|
-
* `message
|
|
164
|
-
* `additional_parameters
|
|
174
|
+
* `application_id` — Application identifier (must be a valid UUID, created in the UI)
|
|
175
|
+
* `message` — The LLM response
|
|
176
|
+
* `additional_parameters` — Optional dictionary with extra context (session, user, agents, etc.)
|
|
165
177
|
|
|
166
|
-
**Response
|
|
178
|
+
**Response example:**
|
|
167
179
|
|
|
168
180
|
```json
|
|
169
181
|
{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
182
|
+
"status": "processed",
|
|
183
|
+
"monitoring_result": {
|
|
184
|
+
"is_toxic": false,
|
|
185
|
+
"type_of_violation": "safe",
|
|
186
|
+
"token_count": 21,
|
|
187
|
+
"token_usage_warning": false,
|
|
188
|
+
"token_usage_unbounded": false
|
|
189
|
+
}
|
|
178
190
|
}
|
|
179
191
|
```
|
|
180
192
|
|
|
193
|
+
---
|
|
194
|
+
|
|
181
195
|
## Sending Requests in Sync Mode
|
|
182
196
|
|
|
183
197
|
```python
|
|
184
198
|
def main():
|
|
185
|
-
#
|
|
199
|
+
# option 1: context manager
|
|
186
200
|
with SyncHivetraceSDK() as client:
|
|
187
201
|
response = client.input(
|
|
188
202
|
application_id="your-application-id",
|
|
189
203
|
message="User prompt here",
|
|
190
204
|
)
|
|
191
205
|
|
|
192
|
-
#
|
|
206
|
+
# option 2: manual close
|
|
193
207
|
client = SyncHivetraceSDK()
|
|
194
208
|
try:
|
|
195
209
|
response = client.input(
|
|
@@ -202,20 +216,22 @@ def main():
|
|
|
202
216
|
main()
|
|
203
217
|
```
|
|
204
218
|
|
|
219
|
+
---
|
|
220
|
+
|
|
205
221
|
## Sending Requests in Async Mode
|
|
206
222
|
|
|
207
223
|
```python
|
|
208
224
|
import asyncio
|
|
209
225
|
|
|
210
226
|
async def main():
|
|
211
|
-
#
|
|
227
|
+
# option 1: context manager
|
|
212
228
|
async with AsyncHivetraceSDK() as client:
|
|
213
229
|
response = await client.input(
|
|
214
230
|
application_id="your-application-id",
|
|
215
231
|
message="User prompt here",
|
|
216
232
|
)
|
|
217
233
|
|
|
218
|
-
#
|
|
234
|
+
# option 2: manual close
|
|
219
235
|
client = AsyncHivetraceSDK()
|
|
220
236
|
try:
|
|
221
237
|
response = await client.input(
|
|
@@ -234,9 +250,17 @@ asyncio.run(main())
|
|
|
234
250
|
await client.close()
|
|
235
251
|
```
|
|
236
252
|
|
|
253
|
+
---
|
|
254
|
+
|
|
237
255
|
## Configuration
|
|
238
256
|
|
|
239
|
-
The SDK
|
|
257
|
+
The SDK reads configuration from environment variables:
|
|
258
|
+
|
|
259
|
+
* `HIVETRACE_URL` — Base URL allowed to call.
|
|
260
|
+
* `HIVETRACE_ACCESS_TOKEN` — API token used for authentication.
|
|
261
|
+
|
|
262
|
+
These are loaded automatically when you create a client.
|
|
263
|
+
|
|
240
264
|
|
|
241
265
|
### Configuration Sources
|
|
242
266
|
|
|
@@ -885,3 +909,8 @@ def calculate_sum(a: int, b: int) -> int:
|
|
|
885
909
|
Add this tool to your agent’s `tools=[...]` — and its calls will appear in HiveTrace with inputs/outputs.
|
|
886
910
|
|
|
887
911
|
---
|
|
912
|
+
|
|
913
|
+
License
|
|
914
|
+
========
|
|
915
|
+
|
|
916
|
+
This project is licensed under Apache License 2.0.
|
|
@@ -2,45 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
Hivetrace SDK
|
|
5
|
+
The Hivetrace SDK lets you integrate with the Hivetrace service to monitor user prompts and LLM responses. It supports both synchronous and asynchronous workflows and can be configured via environment variables.
|
|
6
|
+
|
|
7
|
+
---
|
|
6
8
|
|
|
7
9
|
## Installation
|
|
8
10
|
|
|
9
|
-
Install
|
|
11
|
+
Install from PyPI:
|
|
10
12
|
|
|
11
13
|
```bash
|
|
12
14
|
pip install hivetrace[base]
|
|
13
15
|
```
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
16
20
|
|
|
17
21
|
```python
|
|
18
22
|
from hivetrace import SyncHivetraceSDK, AsyncHivetraceSDK
|
|
19
23
|
```
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
You can use either the synchronous client (`SyncHivetraceSDK`) or the asynchronous client (`AsyncHivetraceSDK`). Choose the one that fits your runtime.
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
---
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
## Synchronous Client
|
|
26
30
|
|
|
27
|
-
|
|
31
|
+
### Initialize (Sync)
|
|
28
32
|
|
|
29
33
|
```python
|
|
30
|
-
#
|
|
34
|
+
# The sync client reads configuration from environment variables or accepts an explicit config
|
|
31
35
|
client = SyncHivetraceSDK()
|
|
32
36
|
```
|
|
33
37
|
|
|
34
|
-
|
|
38
|
+
### Send a user prompt (input)
|
|
35
39
|
|
|
36
40
|
```python
|
|
37
41
|
response = client.input(
|
|
38
|
-
application_id="your-application-id", #
|
|
42
|
+
application_id="your-application-id", # Obtained after registering the application in the UI
|
|
39
43
|
message="User prompt here",
|
|
40
44
|
)
|
|
41
45
|
```
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
### Send an LLM response (output)
|
|
44
48
|
|
|
45
49
|
```python
|
|
46
50
|
response = client.output(
|
|
@@ -49,16 +53,18 @@ response = client.output(
|
|
|
49
53
|
)
|
|
50
54
|
```
|
|
51
55
|
|
|
52
|
-
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Asynchronous Client
|
|
53
59
|
|
|
54
|
-
|
|
60
|
+
### Initialize (Async)
|
|
55
61
|
|
|
56
62
|
```python
|
|
57
|
-
#
|
|
63
|
+
# The async client can be used as a context manager
|
|
58
64
|
client = AsyncHivetraceSDK()
|
|
59
65
|
```
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
### Send a user prompt (input)
|
|
62
68
|
|
|
63
69
|
```python
|
|
64
70
|
response = await client.input(
|
|
@@ -67,7 +73,7 @@ response = await client.input(
|
|
|
67
73
|
)
|
|
68
74
|
```
|
|
69
75
|
|
|
70
|
-
|
|
76
|
+
### Send an LLM response (output)
|
|
71
77
|
|
|
72
78
|
```python
|
|
73
79
|
response = await client.output(
|
|
@@ -76,11 +82,13 @@ response = await client.output(
|
|
|
76
82
|
)
|
|
77
83
|
```
|
|
78
84
|
|
|
85
|
+
---
|
|
86
|
+
|
|
79
87
|
## Example with Additional Parameters
|
|
80
88
|
|
|
81
89
|
```python
|
|
82
90
|
response = client.input(
|
|
83
|
-
application_id="your-application-id",
|
|
91
|
+
application_id="your-application-id",
|
|
84
92
|
message="User prompt here",
|
|
85
93
|
additional_parameters={
|
|
86
94
|
"session_id": "your-session-id",
|
|
@@ -94,7 +102,9 @@ response = client.input(
|
|
|
94
102
|
)
|
|
95
103
|
```
|
|
96
104
|
|
|
97
|
-
> **Note:** `session_id`, `user_id`, and
|
|
105
|
+
> **Note:** `session_id`, `user_id`, and all agent IDs must be valid UUIDs.
|
|
106
|
+
|
|
107
|
+
---
|
|
98
108
|
|
|
99
109
|
## API
|
|
100
110
|
|
|
@@ -108,27 +118,29 @@ def input(application_id: str, message: str, additional_parameters: dict | None
|
|
|
108
118
|
async def input(application_id: str, message: str, additional_parameters: dict | None = None) -> dict: ...
|
|
109
119
|
```
|
|
110
120
|
|
|
111
|
-
Sends a user prompt to Hivetrace.
|
|
121
|
+
Sends a **user prompt** to Hivetrace.
|
|
112
122
|
|
|
113
|
-
* `application_id
|
|
114
|
-
* `message
|
|
115
|
-
* `additional_parameters
|
|
123
|
+
* `application_id` — Application identifier (must be a valid UUID, created in the UI)
|
|
124
|
+
* `message` — The user prompt
|
|
125
|
+
* `additional_parameters` — Optional dictionary with extra context (session, user, agents, etc.)
|
|
116
126
|
|
|
117
|
-
**Response
|
|
127
|
+
**Response example:**
|
|
118
128
|
|
|
119
129
|
```json
|
|
120
130
|
{
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
131
|
+
"status": "processed",
|
|
132
|
+
"monitoring_result": {
|
|
133
|
+
"is_toxic": false,
|
|
134
|
+
"type_of_violation": "benign",
|
|
135
|
+
"token_count": 9,
|
|
136
|
+
"token_usage_warning": false,
|
|
137
|
+
"token_usage_unbounded": false
|
|
138
|
+
}
|
|
129
139
|
}
|
|
130
140
|
```
|
|
131
141
|
|
|
142
|
+
---
|
|
143
|
+
|
|
132
144
|
### `output`
|
|
133
145
|
|
|
134
146
|
```python
|
|
@@ -139,39 +151,41 @@ def output(application_id: str, message: str, additional_parameters: dict | None
|
|
|
139
151
|
async def output(application_id: str, message: str, additional_parameters: dict | None = None) -> dict: ...
|
|
140
152
|
```
|
|
141
153
|
|
|
142
|
-
Sends an LLM response to Hivetrace.
|
|
154
|
+
Sends an **LLM response** to Hivetrace.
|
|
143
155
|
|
|
144
|
-
* `application_id
|
|
145
|
-
* `message
|
|
146
|
-
* `additional_parameters
|
|
156
|
+
* `application_id` — Application identifier (must be a valid UUID, created in the UI)
|
|
157
|
+
* `message` — The LLM response
|
|
158
|
+
* `additional_parameters` — Optional dictionary with extra context (session, user, agents, etc.)
|
|
147
159
|
|
|
148
|
-
**Response
|
|
160
|
+
**Response example:**
|
|
149
161
|
|
|
150
162
|
```json
|
|
151
163
|
{
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
164
|
+
"status": "processed",
|
|
165
|
+
"monitoring_result": {
|
|
166
|
+
"is_toxic": false,
|
|
167
|
+
"type_of_violation": "safe",
|
|
168
|
+
"token_count": 21,
|
|
169
|
+
"token_usage_warning": false,
|
|
170
|
+
"token_usage_unbounded": false
|
|
171
|
+
}
|
|
160
172
|
}
|
|
161
173
|
```
|
|
162
174
|
|
|
175
|
+
---
|
|
176
|
+
|
|
163
177
|
## Sending Requests in Sync Mode
|
|
164
178
|
|
|
165
179
|
```python
|
|
166
180
|
def main():
|
|
167
|
-
#
|
|
181
|
+
# option 1: context manager
|
|
168
182
|
with SyncHivetraceSDK() as client:
|
|
169
183
|
response = client.input(
|
|
170
184
|
application_id="your-application-id",
|
|
171
185
|
message="User prompt here",
|
|
172
186
|
)
|
|
173
187
|
|
|
174
|
-
#
|
|
188
|
+
# option 2: manual close
|
|
175
189
|
client = SyncHivetraceSDK()
|
|
176
190
|
try:
|
|
177
191
|
response = client.input(
|
|
@@ -184,20 +198,22 @@ def main():
|
|
|
184
198
|
main()
|
|
185
199
|
```
|
|
186
200
|
|
|
201
|
+
---
|
|
202
|
+
|
|
187
203
|
## Sending Requests in Async Mode
|
|
188
204
|
|
|
189
205
|
```python
|
|
190
206
|
import asyncio
|
|
191
207
|
|
|
192
208
|
async def main():
|
|
193
|
-
#
|
|
209
|
+
# option 1: context manager
|
|
194
210
|
async with AsyncHivetraceSDK() as client:
|
|
195
211
|
response = await client.input(
|
|
196
212
|
application_id="your-application-id",
|
|
197
213
|
message="User prompt here",
|
|
198
214
|
)
|
|
199
215
|
|
|
200
|
-
#
|
|
216
|
+
# option 2: manual close
|
|
201
217
|
client = AsyncHivetraceSDK()
|
|
202
218
|
try:
|
|
203
219
|
response = await client.input(
|
|
@@ -216,9 +232,17 @@ asyncio.run(main())
|
|
|
216
232
|
await client.close()
|
|
217
233
|
```
|
|
218
234
|
|
|
235
|
+
---
|
|
236
|
+
|
|
219
237
|
## Configuration
|
|
220
238
|
|
|
221
|
-
The SDK
|
|
239
|
+
The SDK reads configuration from environment variables:
|
|
240
|
+
|
|
241
|
+
* `HIVETRACE_URL` — Base URL allowed to call.
|
|
242
|
+
* `HIVETRACE_ACCESS_TOKEN` — API token used for authentication.
|
|
243
|
+
|
|
244
|
+
These are loaded automatically when you create a client.
|
|
245
|
+
|
|
222
246
|
|
|
223
247
|
### Configuration Sources
|
|
224
248
|
|
|
@@ -867,3 +891,8 @@ def calculate_sum(a: int, b: int) -> int:
|
|
|
867
891
|
Add this tool to your agent’s `tools=[...]` — and its calls will appear in HiveTrace with inputs/outputs.
|
|
868
892
|
|
|
869
893
|
---
|
|
894
|
+
|
|
895
|
+
License
|
|
896
|
+
========
|
|
897
|
+
|
|
898
|
+
This project is licensed under Apache License 2.0.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: hivetrace
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.8
|
|
4
4
|
Summary: Hivetrace SDK for monitoring LLM applications
|
|
5
5
|
Home-page: http://hivetrace.ai
|
|
6
6
|
Author: Raft
|
|
@@ -20,45 +20,49 @@ License-File: LICENSE
|
|
|
20
20
|
|
|
21
21
|
## Overview
|
|
22
22
|
|
|
23
|
-
Hivetrace SDK
|
|
23
|
+
The Hivetrace SDK lets you integrate with the Hivetrace service to monitor user prompts and LLM responses. It supports both synchronous and asynchronous workflows and can be configured via environment variables.
|
|
24
|
+
|
|
25
|
+
---
|
|
24
26
|
|
|
25
27
|
## Installation
|
|
26
28
|
|
|
27
|
-
Install
|
|
29
|
+
Install from PyPI:
|
|
28
30
|
|
|
29
31
|
```bash
|
|
30
32
|
pip install hivetrace[base]
|
|
31
33
|
```
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Quick Start
|
|
34
38
|
|
|
35
39
|
```python
|
|
36
40
|
from hivetrace import SyncHivetraceSDK, AsyncHivetraceSDK
|
|
37
41
|
```
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
You can use either the synchronous client (`SyncHivetraceSDK`) or the asynchronous client (`AsyncHivetraceSDK`). Choose the one that fits your runtime.
|
|
40
44
|
|
|
41
|
-
|
|
45
|
+
---
|
|
42
46
|
|
|
43
|
-
|
|
47
|
+
## Synchronous Client
|
|
44
48
|
|
|
45
|
-
|
|
49
|
+
### Initialize (Sync)
|
|
46
50
|
|
|
47
51
|
```python
|
|
48
|
-
#
|
|
52
|
+
# The sync client reads configuration from environment variables or accepts an explicit config
|
|
49
53
|
client = SyncHivetraceSDK()
|
|
50
54
|
```
|
|
51
55
|
|
|
52
|
-
|
|
56
|
+
### Send a user prompt (input)
|
|
53
57
|
|
|
54
58
|
```python
|
|
55
59
|
response = client.input(
|
|
56
|
-
application_id="your-application-id", #
|
|
60
|
+
application_id="your-application-id", # Obtained after registering the application in the UI
|
|
57
61
|
message="User prompt here",
|
|
58
62
|
)
|
|
59
63
|
```
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
### Send an LLM response (output)
|
|
62
66
|
|
|
63
67
|
```python
|
|
64
68
|
response = client.output(
|
|
@@ -67,16 +71,18 @@ response = client.output(
|
|
|
67
71
|
)
|
|
68
72
|
```
|
|
69
73
|
|
|
70
|
-
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Asynchronous Client
|
|
71
77
|
|
|
72
|
-
|
|
78
|
+
### Initialize (Async)
|
|
73
79
|
|
|
74
80
|
```python
|
|
75
|
-
#
|
|
81
|
+
# The async client can be used as a context manager
|
|
76
82
|
client = AsyncHivetraceSDK()
|
|
77
83
|
```
|
|
78
84
|
|
|
79
|
-
|
|
85
|
+
### Send a user prompt (input)
|
|
80
86
|
|
|
81
87
|
```python
|
|
82
88
|
response = await client.input(
|
|
@@ -85,7 +91,7 @@ response = await client.input(
|
|
|
85
91
|
)
|
|
86
92
|
```
|
|
87
93
|
|
|
88
|
-
|
|
94
|
+
### Send an LLM response (output)
|
|
89
95
|
|
|
90
96
|
```python
|
|
91
97
|
response = await client.output(
|
|
@@ -94,11 +100,13 @@ response = await client.output(
|
|
|
94
100
|
)
|
|
95
101
|
```
|
|
96
102
|
|
|
103
|
+
---
|
|
104
|
+
|
|
97
105
|
## Example with Additional Parameters
|
|
98
106
|
|
|
99
107
|
```python
|
|
100
108
|
response = client.input(
|
|
101
|
-
application_id="your-application-id",
|
|
109
|
+
application_id="your-application-id",
|
|
102
110
|
message="User prompt here",
|
|
103
111
|
additional_parameters={
|
|
104
112
|
"session_id": "your-session-id",
|
|
@@ -112,7 +120,9 @@ response = client.input(
|
|
|
112
120
|
)
|
|
113
121
|
```
|
|
114
122
|
|
|
115
|
-
> **Note:** `session_id`, `user_id`, and
|
|
123
|
+
> **Note:** `session_id`, `user_id`, and all agent IDs must be valid UUIDs.
|
|
124
|
+
|
|
125
|
+
---
|
|
116
126
|
|
|
117
127
|
## API
|
|
118
128
|
|
|
@@ -126,27 +136,29 @@ def input(application_id: str, message: str, additional_parameters: dict | None
|
|
|
126
136
|
async def input(application_id: str, message: str, additional_parameters: dict | None = None) -> dict: ...
|
|
127
137
|
```
|
|
128
138
|
|
|
129
|
-
Sends a user prompt to Hivetrace.
|
|
139
|
+
Sends a **user prompt** to Hivetrace.
|
|
130
140
|
|
|
131
|
-
* `application_id
|
|
132
|
-
* `message
|
|
133
|
-
* `additional_parameters
|
|
141
|
+
* `application_id` — Application identifier (must be a valid UUID, created in the UI)
|
|
142
|
+
* `message` — The user prompt
|
|
143
|
+
* `additional_parameters` — Optional dictionary with extra context (session, user, agents, etc.)
|
|
134
144
|
|
|
135
|
-
**Response
|
|
145
|
+
**Response example:**
|
|
136
146
|
|
|
137
147
|
```json
|
|
138
148
|
{
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
"status": "processed",
|
|
150
|
+
"monitoring_result": {
|
|
151
|
+
"is_toxic": false,
|
|
152
|
+
"type_of_violation": "benign",
|
|
153
|
+
"token_count": 9,
|
|
154
|
+
"token_usage_warning": false,
|
|
155
|
+
"token_usage_unbounded": false
|
|
156
|
+
}
|
|
147
157
|
}
|
|
148
158
|
```
|
|
149
159
|
|
|
160
|
+
---
|
|
161
|
+
|
|
150
162
|
### `output`
|
|
151
163
|
|
|
152
164
|
```python
|
|
@@ -157,39 +169,41 @@ def output(application_id: str, message: str, additional_parameters: dict | None
|
|
|
157
169
|
async def output(application_id: str, message: str, additional_parameters: dict | None = None) -> dict: ...
|
|
158
170
|
```
|
|
159
171
|
|
|
160
|
-
Sends an LLM response to Hivetrace.
|
|
172
|
+
Sends an **LLM response** to Hivetrace.
|
|
161
173
|
|
|
162
|
-
* `application_id
|
|
163
|
-
* `message
|
|
164
|
-
* `additional_parameters
|
|
174
|
+
* `application_id` — Application identifier (must be a valid UUID, created in the UI)
|
|
175
|
+
* `message` — The LLM response
|
|
176
|
+
* `additional_parameters` — Optional dictionary with extra context (session, user, agents, etc.)
|
|
165
177
|
|
|
166
|
-
**Response
|
|
178
|
+
**Response example:**
|
|
167
179
|
|
|
168
180
|
```json
|
|
169
181
|
{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
182
|
+
"status": "processed",
|
|
183
|
+
"monitoring_result": {
|
|
184
|
+
"is_toxic": false,
|
|
185
|
+
"type_of_violation": "safe",
|
|
186
|
+
"token_count": 21,
|
|
187
|
+
"token_usage_warning": false,
|
|
188
|
+
"token_usage_unbounded": false
|
|
189
|
+
}
|
|
178
190
|
}
|
|
179
191
|
```
|
|
180
192
|
|
|
193
|
+
---
|
|
194
|
+
|
|
181
195
|
## Sending Requests in Sync Mode
|
|
182
196
|
|
|
183
197
|
```python
|
|
184
198
|
def main():
|
|
185
|
-
#
|
|
199
|
+
# option 1: context manager
|
|
186
200
|
with SyncHivetraceSDK() as client:
|
|
187
201
|
response = client.input(
|
|
188
202
|
application_id="your-application-id",
|
|
189
203
|
message="User prompt here",
|
|
190
204
|
)
|
|
191
205
|
|
|
192
|
-
#
|
|
206
|
+
# option 2: manual close
|
|
193
207
|
client = SyncHivetraceSDK()
|
|
194
208
|
try:
|
|
195
209
|
response = client.input(
|
|
@@ -202,20 +216,22 @@ def main():
|
|
|
202
216
|
main()
|
|
203
217
|
```
|
|
204
218
|
|
|
219
|
+
---
|
|
220
|
+
|
|
205
221
|
## Sending Requests in Async Mode
|
|
206
222
|
|
|
207
223
|
```python
|
|
208
224
|
import asyncio
|
|
209
225
|
|
|
210
226
|
async def main():
|
|
211
|
-
#
|
|
227
|
+
# option 1: context manager
|
|
212
228
|
async with AsyncHivetraceSDK() as client:
|
|
213
229
|
response = await client.input(
|
|
214
230
|
application_id="your-application-id",
|
|
215
231
|
message="User prompt here",
|
|
216
232
|
)
|
|
217
233
|
|
|
218
|
-
#
|
|
234
|
+
# option 2: manual close
|
|
219
235
|
client = AsyncHivetraceSDK()
|
|
220
236
|
try:
|
|
221
237
|
response = await client.input(
|
|
@@ -234,9 +250,17 @@ asyncio.run(main())
|
|
|
234
250
|
await client.close()
|
|
235
251
|
```
|
|
236
252
|
|
|
253
|
+
---
|
|
254
|
+
|
|
237
255
|
## Configuration
|
|
238
256
|
|
|
239
|
-
The SDK
|
|
257
|
+
The SDK reads configuration from environment variables:
|
|
258
|
+
|
|
259
|
+
* `HIVETRACE_URL` — Base URL allowed to call.
|
|
260
|
+
* `HIVETRACE_ACCESS_TOKEN` — API token used for authentication.
|
|
261
|
+
|
|
262
|
+
These are loaded automatically when you create a client.
|
|
263
|
+
|
|
240
264
|
|
|
241
265
|
### Configuration Sources
|
|
242
266
|
|
|
@@ -885,3 +909,8 @@ def calculate_sum(a: int, b: int) -> int:
|
|
|
885
909
|
Add this tool to your agent’s `tools=[...]` — and its calls will appear in HiveTrace with inputs/outputs.
|
|
886
910
|
|
|
887
911
|
---
|
|
912
|
+
|
|
913
|
+
License
|
|
914
|
+
========
|
|
915
|
+
|
|
916
|
+
This project is licensed under Apache License 2.0.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|