docent-python 0.1.8a0__py3-none-any.whl → 0.1.10a0__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 docent-python might be problematic. Click here for more details.
- docent/data_models/chat/__init__.py +2 -1
- docent/sdk/client.py +33 -31
- docent/trace.py +19 -2
- {docent_python-0.1.8a0.dist-info → docent_python-0.1.10a0.dist-info}/METADATA +1 -1
- {docent_python-0.1.8a0.dist-info → docent_python-0.1.10a0.dist-info}/RECORD +7 -7
- {docent_python-0.1.8a0.dist-info → docent_python-0.1.10a0.dist-info}/WHEEL +0 -0
- {docent_python-0.1.8a0.dist-info → docent_python-0.1.10a0.dist-info}/licenses/LICENSE.md +0 -0
|
@@ -7,7 +7,7 @@ from docent.data_models.chat.message import (
|
|
|
7
7
|
UserMessage,
|
|
8
8
|
parse_chat_message,
|
|
9
9
|
)
|
|
10
|
-
from docent.data_models.chat.tool import ToolCall, ToolInfo, ToolParams
|
|
10
|
+
from docent.data_models.chat.tool import ToolCall, ToolCallContent, ToolInfo, ToolParams
|
|
11
11
|
|
|
12
12
|
__all__ = [
|
|
13
13
|
"ChatMessage",
|
|
@@ -19,6 +19,7 @@ __all__ = [
|
|
|
19
19
|
"ContentReasoning",
|
|
20
20
|
"ContentText",
|
|
21
21
|
"ToolCall",
|
|
22
|
+
"ToolCallContent",
|
|
22
23
|
"ToolInfo",
|
|
23
24
|
"ToolParams",
|
|
24
25
|
"parse_chat_message",
|
docent/sdk/client.py
CHANGED
|
@@ -196,7 +196,7 @@ class Docent:
|
|
|
196
196
|
response.raise_for_status()
|
|
197
197
|
return response.json()
|
|
198
198
|
|
|
199
|
-
def
|
|
199
|
+
def list_rubrics(self, collection_id: str) -> list[dict[str, Any]]:
|
|
200
200
|
"""List all rubrics for a given collection.
|
|
201
201
|
|
|
202
202
|
Args:
|
|
@@ -213,71 +213,73 @@ class Docent:
|
|
|
213
213
|
response.raise_for_status()
|
|
214
214
|
return response.json()
|
|
215
215
|
|
|
216
|
-
def
|
|
217
|
-
|
|
218
|
-
) -> list[dict[str, Any]]:
|
|
219
|
-
"""Get rubric results for a given collection, rubric and version.
|
|
216
|
+
def get_rubric_run_state(self, collection_id: str, rubric_id: str) -> dict[str, Any]:
|
|
217
|
+
"""Get rubric run state for a given collection and rubric.
|
|
220
218
|
|
|
221
219
|
Args:
|
|
222
220
|
collection_id: ID of the Collection.
|
|
223
|
-
rubric_id: The ID of the rubric to get
|
|
224
|
-
rubric_version: The version of the rubric to get results for.
|
|
221
|
+
rubric_id: The ID of the rubric to get run state for.
|
|
225
222
|
|
|
226
223
|
Returns:
|
|
227
|
-
|
|
224
|
+
dict: Dictionary containing rubric run state with results, job_id, and total_agent_runs.
|
|
228
225
|
|
|
229
226
|
Raises:
|
|
230
227
|
requests.exceptions.HTTPError: If the API request fails.
|
|
231
228
|
"""
|
|
232
|
-
url = f"{self._server_url}/rubric/{collection_id}/{rubric_id}/
|
|
233
|
-
response = self._session.get(url
|
|
229
|
+
url = f"{self._server_url}/rubric/{collection_id}/{rubric_id}/rubric_run_state"
|
|
230
|
+
response = self._session.get(url)
|
|
234
231
|
response.raise_for_status()
|
|
235
232
|
return response.json()
|
|
236
233
|
|
|
237
|
-
def
|
|
238
|
-
|
|
239
|
-
) -> list[dict[str, Any]]:
|
|
240
|
-
"""List all centroids for a given collection and rubric.
|
|
234
|
+
def get_clustering_state(self, collection_id: str, rubric_id: str) -> dict[str, Any]:
|
|
235
|
+
"""Get clustering state for a given collection and rubric.
|
|
241
236
|
|
|
242
237
|
Args:
|
|
243
238
|
collection_id: ID of the Collection.
|
|
244
|
-
rubric_id: The ID of the rubric to get
|
|
245
|
-
rubric_version: Optional version of the rubric. If not provided, uses latest.
|
|
239
|
+
rubric_id: The ID of the rubric to get clustering state for.
|
|
246
240
|
|
|
247
241
|
Returns:
|
|
248
|
-
|
|
242
|
+
dict: Dictionary containing job_id, centroids, and assignments.
|
|
249
243
|
|
|
250
244
|
Raises:
|
|
251
245
|
requests.exceptions.HTTPError: If the API request fails.
|
|
252
246
|
"""
|
|
253
|
-
url = f"{self._server_url}/rubric/{collection_id}/{rubric_id}/
|
|
254
|
-
|
|
255
|
-
if rubric_version is not None:
|
|
256
|
-
params["rubric_version"] = rubric_version
|
|
257
|
-
response = self._session.get(url, params=params)
|
|
247
|
+
url = f"{self._server_url}/rubric/{collection_id}/{rubric_id}/clustering_job"
|
|
248
|
+
response = self._session.get(url)
|
|
258
249
|
response.raise_for_status()
|
|
259
250
|
return response.json()
|
|
260
251
|
|
|
261
|
-
def
|
|
262
|
-
|
|
263
|
-
|
|
252
|
+
def get_cluster_centroids(self, collection_id: str, rubric_id: str) -> list[dict[str, Any]]:
|
|
253
|
+
"""Get centroids for a given collection and rubric.
|
|
254
|
+
|
|
255
|
+
Args:
|
|
256
|
+
collection_id: ID of the Collection.
|
|
257
|
+
rubric_id: The ID of the rubric to get centroids for.
|
|
258
|
+
|
|
259
|
+
Returns:
|
|
260
|
+
list: List of dictionaries containing centroid information.
|
|
261
|
+
|
|
262
|
+
Raises:
|
|
263
|
+
requests.exceptions.HTTPError: If the API request fails.
|
|
264
|
+
"""
|
|
265
|
+
clustering_state = self.get_clustering_state(collection_id, rubric_id)
|
|
266
|
+
return clustering_state.get("centroids", [])
|
|
267
|
+
|
|
268
|
+
def get_cluster_assignments(self, collection_id: str, rubric_id: str) -> dict[str, list[str]]:
|
|
264
269
|
"""Get centroid assignments for a given rubric.
|
|
265
270
|
|
|
266
271
|
Args:
|
|
267
272
|
collection_id: ID of the Collection.
|
|
268
273
|
rubric_id: The ID of the rubric to get assignments for.
|
|
269
|
-
rubric_version: The version of the rubric to get assignments for.
|
|
270
274
|
|
|
271
275
|
Returns:
|
|
272
|
-
|
|
276
|
+
dict: Dictionary mapping centroid IDs to lists of judge result IDs.
|
|
273
277
|
|
|
274
278
|
Raises:
|
|
275
279
|
requests.exceptions.HTTPError: If the API request fails.
|
|
276
280
|
"""
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
response.raise_for_status()
|
|
280
|
-
return response.json()
|
|
281
|
+
clustering_state = self.get_clustering_state(collection_id, rubric_id)
|
|
282
|
+
return clustering_state.get("assignments", {})
|
|
281
283
|
|
|
282
284
|
def get_agent_run(self, collection_id: str, agent_run_id: str) -> AgentRun | None:
|
|
283
285
|
"""Get a specific agent run by its ID.
|
docent/trace.py
CHANGED
|
@@ -200,7 +200,6 @@ class DocentTracer:
|
|
|
200
200
|
def _signal_handler(self, signum: int, frame: Optional[object]):
|
|
201
201
|
"""Handle shutdown signals."""
|
|
202
202
|
self.cleanup()
|
|
203
|
-
sys.exit(0)
|
|
204
203
|
|
|
205
204
|
def _init_spans_exporter(self, endpoint: str) -> Optional[Union[HTTPExporter, GRPCExporter]]:
|
|
206
205
|
"""Initialize the appropriate span exporter based on endpoint."""
|
|
@@ -463,6 +462,10 @@ class DocentTracer:
|
|
|
463
462
|
except Exception as e:
|
|
464
463
|
logger.error(f"Error during flush: {e}")
|
|
465
464
|
|
|
465
|
+
def is_disabled(self) -> bool:
|
|
466
|
+
"""Check if tracing is disabled."""
|
|
467
|
+
return self._disabled
|
|
468
|
+
|
|
466
469
|
def set_disabled(self, disabled: bool) -> None:
|
|
467
470
|
"""Enable or disable tracing."""
|
|
468
471
|
self._disabled = disabled
|
|
@@ -616,9 +619,10 @@ class DocentTracer:
|
|
|
616
619
|
Returns:
|
|
617
620
|
Dictionary of headers including Authorization
|
|
618
621
|
"""
|
|
622
|
+
|
|
619
623
|
return {
|
|
620
624
|
"Content-Type": "application/json",
|
|
621
|
-
"Authorization":
|
|
625
|
+
"Authorization": self.headers.get("Authorization", ""),
|
|
622
626
|
}
|
|
623
627
|
|
|
624
628
|
def _post_json(self, path: str, data: Dict[str, Any]) -> None:
|
|
@@ -1163,6 +1167,13 @@ def verify_initialized() -> bool:
|
|
|
1163
1167
|
return _global_tracer.verify_initialized()
|
|
1164
1168
|
|
|
1165
1169
|
|
|
1170
|
+
def is_disabled() -> bool:
|
|
1171
|
+
"""Check if global tracing is disabled."""
|
|
1172
|
+
if _global_tracer:
|
|
1173
|
+
return _global_tracer.is_disabled()
|
|
1174
|
+
return True
|
|
1175
|
+
|
|
1176
|
+
|
|
1166
1177
|
def set_disabled(disabled: bool) -> None:
|
|
1167
1178
|
"""Enable or disable global tracing."""
|
|
1168
1179
|
if _global_tracer:
|
|
@@ -1180,6 +1191,8 @@ def agent_run_score(name: str, score: float, attributes: Optional[Dict[str, Any]
|
|
|
1180
1191
|
"""
|
|
1181
1192
|
try:
|
|
1182
1193
|
tracer: DocentTracer = get_tracer()
|
|
1194
|
+
if tracer.is_disabled():
|
|
1195
|
+
return
|
|
1183
1196
|
agent_run_id = tracer.get_current_agent_run_id()
|
|
1184
1197
|
|
|
1185
1198
|
if not agent_run_id:
|
|
@@ -1216,6 +1229,8 @@ def agent_run_metadata(metadata: Dict[str, Any]) -> None:
|
|
|
1216
1229
|
"""
|
|
1217
1230
|
try:
|
|
1218
1231
|
tracer = get_tracer()
|
|
1232
|
+
if tracer.is_disabled():
|
|
1233
|
+
return
|
|
1219
1234
|
agent_run_id = tracer.get_current_agent_run_id()
|
|
1220
1235
|
if not agent_run_id:
|
|
1221
1236
|
logger.warning("No active agent run context. Metadata will not be sent.")
|
|
@@ -1248,6 +1263,8 @@ def transcript_metadata(
|
|
|
1248
1263
|
"""
|
|
1249
1264
|
try:
|
|
1250
1265
|
tracer = get_tracer()
|
|
1266
|
+
if tracer.is_disabled():
|
|
1267
|
+
return
|
|
1251
1268
|
transcript_id = tracer.get_current_transcript_id()
|
|
1252
1269
|
if not transcript_id:
|
|
1253
1270
|
logger.warning("No active transcript context. Metadata will not be sent.")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
docent/__init__.py,sha256=J2BbO6rzilfw9WXRUeolr439EGFezqbMU_kCpCCryRA,59
|
|
2
2
|
docent/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
docent/trace.py,sha256
|
|
3
|
+
docent/trace.py,sha256=-3QbmAjZJfKZp9pmhLne0EIB-akbz2XbEDNqpsROEco,66513
|
|
4
4
|
docent/trace_temp.py,sha256=Z0lAPwVzXjFvxpiU-CuvfWIslq9Q4alNkZMoQ77Xudk,40711
|
|
5
5
|
docent/_log_util/__init__.py,sha256=3HXXrxrSm8PxwG4llotrCnSnp7GuroK1FNHsdg6f7aE,73
|
|
6
6
|
docent/_log_util/logger.py,sha256=kwM0yRW1IJd6-XTorjWn48B4l8qvD2ZM6VDjY5eskQI,4422
|
|
@@ -12,7 +12,7 @@ docent/data_models/metadata.py,sha256=r0SYC4i2x096dXMLfw_rAMtcJQCsoV6EOMPZuEngbG
|
|
|
12
12
|
docent/data_models/regex.py,sha256=0ciIerkrNwb91bY5mTcyO5nDWH67xx2tZYObV52fmBo,1684
|
|
13
13
|
docent/data_models/shared_types.py,sha256=jjm-Dh5S6v7UKInW7SEqoziOsx6Z7Uu4e3VzgCbTWvc,225
|
|
14
14
|
docent/data_models/transcript.py,sha256=0iF2ujcWhTss8WkkpNMeIKJyKOfMEsiMoAQMGwY4ing,15753
|
|
15
|
-
docent/data_models/chat/__init__.py,sha256=
|
|
15
|
+
docent/data_models/chat/__init__.py,sha256=GleyRzYqKRkwwSRm_tQJw5BudCbgu9WRSa71Fntz0L0,610
|
|
16
16
|
docent/data_models/chat/content.py,sha256=Co-jO8frQa_DSP11wJuhPX0s-GpJk8yqtKqPeiAIZ_U,1672
|
|
17
17
|
docent/data_models/chat/message.py,sha256=iAo38kbV6wYbFh8S23cxLy6HY4C_i3PzQ6RpSQG5dxM,3861
|
|
18
18
|
docent/data_models/chat/tool.py,sha256=x7NKINswPe0Kqvcx4ubjHzB-n0-i4DbFodvaBb2vitk,3042
|
|
@@ -22,8 +22,8 @@ docent/samples/load.py,sha256=ZGE07r83GBNO4A0QBh5aQ18WAu3mTWA1vxUoHd90nrM,207
|
|
|
22
22
|
docent/samples/log.eval,sha256=orrW__9WBfANq7NwKsPSq9oTsQRcG6KohG5tMr_X_XY,397708
|
|
23
23
|
docent/samples/tb_airline.json,sha256=eR2jFFRtOw06xqbEglh6-dPewjifOk-cuxJq67Dtu5I,47028
|
|
24
24
|
docent/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
|
-
docent/sdk/client.py,sha256=
|
|
26
|
-
docent_python-0.1.
|
|
27
|
-
docent_python-0.1.
|
|
28
|
-
docent_python-0.1.
|
|
29
|
-
docent_python-0.1.
|
|
25
|
+
docent/sdk/client.py,sha256=D4_4nFS0Ih3ZPfDDmOG-TQ_VUnl1EnsMAPJgYirke5A,12768
|
|
26
|
+
docent_python-0.1.10a0.dist-info/METADATA,sha256=AxER6mbCg-7cusC20tBqw3d15eTClWJZaPcS8U74iSw,1038
|
|
27
|
+
docent_python-0.1.10a0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
28
|
+
docent_python-0.1.10a0.dist-info/licenses/LICENSE.md,sha256=vOHzq3K4Ndu0UV9hPrtXvlD7pHOjyDQmGjHuLSIkRQY,1087
|
|
29
|
+
docent_python-0.1.10a0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|