docent-python 0.1.23a0__py3-none-any.whl → 0.1.25a0__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.

@@ -18,8 +18,13 @@ from openai import (
18
18
  PermissionDeniedError,
19
19
  RateLimitError,
20
20
  UnprocessableEntityError,
21
- omit,
22
21
  )
22
+ try:
23
+ from openai import omit
24
+ except ImportError:
25
+ from openai import Omit as _OpenAIOmit
26
+
27
+ omit = _OpenAIOmit()
23
28
  from openai.types.chat import (
24
29
  ChatCompletion,
25
30
  ChatCompletionAssistantMessageParam,
docent/sdk/client.py CHANGED
@@ -391,6 +391,24 @@ class Docent:
391
391
  # TODO(mengk): kinda hacky
392
392
  return AgentRun.model_validate(response.json())
393
393
 
394
+ def get_chat_sessions(self, collection_id: str, agent_run_id: str) -> list[dict[str, Any]]:
395
+ """Get all chat sessions for an agent run, excluding judge result sessions.
396
+
397
+ Args:
398
+ collection_id: ID of the Collection.
399
+ agent_run_id: The ID of the agent run to retrieve chat sessions for.
400
+
401
+ Returns:
402
+ list: List of chat session dictionaries.
403
+
404
+ Raises:
405
+ requests.exceptions.HTTPError: If the API request fails.
406
+ """
407
+ url = f"{self._server_url}/chat/{collection_id}/{agent_run_id}/sessions"
408
+ response = self._session.get(url)
409
+ self._handle_response_errors(response)
410
+ return response.json()
411
+
394
412
  def make_collection_public(self, collection_id: str) -> dict[str, Any]:
395
413
  """Make a collection publicly accessible to anyone with the link.
396
414
 
docent/trace.py CHANGED
@@ -129,6 +129,8 @@ class DocentTracer:
129
129
  lambda: itertools.count(0)
130
130
  )
131
131
  self._transcript_counter_lock = threading.Lock()
132
+ self._transcript_group_states: dict[str, dict[str, Optional[str]]] = {}
133
+ self._transcript_group_state_lock = threading.Lock()
132
134
  self._flush_lock = threading.Lock()
133
135
 
134
136
  def get_current_agent_run_id(self) -> Optional[str]:
@@ -888,6 +890,27 @@ class DocentTracer:
888
890
  )
889
891
  return
890
892
 
893
+ with self._transcript_group_state_lock:
894
+ state: dict[str, Optional[str]] = self._transcript_group_states.setdefault(
895
+ transcript_group_id, {}
896
+ )
897
+ final_name: Optional[str] = name if name is not None else state.get("name")
898
+ final_description: Optional[str] = (
899
+ description if description is not None else state.get("description")
900
+ )
901
+ final_parent_transcript_group_id: Optional[str] = (
902
+ parent_transcript_group_id
903
+ if parent_transcript_group_id is not None
904
+ else state.get("parent_transcript_group_id")
905
+ )
906
+
907
+ if final_name is not None:
908
+ state["name"] = final_name
909
+ if final_description is not None:
910
+ state["description"] = final_description
911
+ if final_parent_transcript_group_id is not None:
912
+ state["parent_transcript_group_id"] = final_parent_transcript_group_id
913
+
891
914
  payload: Dict[str, Any] = {
892
915
  "collection_id": collection_id,
893
916
  "transcript_group_id": transcript_group_id,
@@ -895,12 +918,12 @@ class DocentTracer:
895
918
  "timestamp": datetime.now(timezone.utc).isoformat(),
896
919
  }
897
920
 
898
- if name is not None:
899
- payload["name"] = name
900
- if description is not None:
901
- payload["description"] = description
902
- if parent_transcript_group_id is not None:
903
- payload["parent_transcript_group_id"] = parent_transcript_group_id
921
+ if final_name is not None:
922
+ payload["name"] = final_name
923
+ if final_description is not None:
924
+ payload["description"] = final_description
925
+ if final_parent_transcript_group_id is not None:
926
+ payload["parent_transcript_group_id"] = final_parent_transcript_group_id
904
927
  if metadata is not None:
905
928
  payload["metadata"] = metadata
906
929
 
@@ -1270,6 +1293,41 @@ def transcript_metadata(
1270
1293
  logger.error(f"Failed to send transcript metadata: {e}")
1271
1294
 
1272
1295
 
1296
+ def transcript_group_metadata(
1297
+ name: Optional[str] = None,
1298
+ description: Optional[str] = None,
1299
+ parent_transcript_group_id: Optional[str] = None,
1300
+ metadata: Optional[Dict[str, Any]] = None,
1301
+ ) -> None:
1302
+ """
1303
+ Send transcript group metadata directly to the backend for the current transcript group.
1304
+
1305
+ Args:
1306
+ name: Optional transcript group name
1307
+ description: Optional transcript group description
1308
+ parent_transcript_group_id: Optional parent transcript group ID
1309
+ metadata: Optional metadata to send
1310
+
1311
+ Example:
1312
+ transcript_group_metadata(name="pipeline", description="Main processing pipeline")
1313
+ transcript_group_metadata(metadata={"team": "search", "env": "prod"})
1314
+ """
1315
+ try:
1316
+ tracer = get_tracer()
1317
+ if tracer.is_disabled():
1318
+ return
1319
+ transcript_group_id = tracer.get_current_transcript_group_id()
1320
+ if not transcript_group_id:
1321
+ logger.warning("No active transcript group context. Metadata will not be sent.")
1322
+ return
1323
+
1324
+ tracer.send_transcript_group_metadata(
1325
+ transcript_group_id, name, description, parent_transcript_group_id, metadata
1326
+ )
1327
+ except Exception as e:
1328
+ logger.error(f"Failed to send transcript group metadata: {e}")
1329
+
1330
+
1273
1331
  class AgentRunContext:
1274
1332
  """Context manager that works in both sync and async contexts."""
1275
1333
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docent-python
3
- Version: 0.1.23a0
3
+ Version: 0.1.25a0
4
4
  Summary: Docent SDK
5
5
  Project-URL: Homepage, https://github.com/TransluceAI/docent
6
6
  Project-URL: Issues, https://github.com/TransluceAI/docent/issues
@@ -1,6 +1,6 @@
1
1
  docent/__init__.py,sha256=fuhETwJPcesiB76Zxa64HBJxeaaTyRalIH-fs77TWsU,112
2
2
  docent/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- docent/trace.py,sha256=u_1M_B1ncCR5a0Yy5ppQY_0k0AFYe4UhSIGeTuZCH0w,67271
3
+ docent/trace.py,sha256=loJJDD3AX-rrP-QsZ8WkkFPxKd4u9wiiBG0gtxSgY0I,69743
4
4
  docent/trace_temp.py,sha256=Z0lAPwVzXjFvxpiU-CuvfWIslq9Q4alNkZMoQ77Xudk,40711
5
5
  docent/_llm_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  docent/_llm_util/llm_cache.py,sha256=nGrvfFikFbEnfmzZRvWvZ60gfVSTvW1iC8-ciCXwbAk,6430
@@ -13,7 +13,7 @@ docent/_llm_util/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
13
13
  docent/_llm_util/providers/anthropic.py,sha256=-1oPd5FB4aFwKSmNvXzG8PVewjhgsogLRX1SCpnCxoA,18720
14
14
  docent/_llm_util/providers/common.py,sha256=dgcTuU4XkCKoAaM48UW8zMgRYUzj7TDBhvWqtnxBO7g,1166
15
15
  docent/_llm_util/providers/google.py,sha256=2D9mDgenZW0pt0_V7koX-aoZzpl8jo8xE5EWOLK7I0k,20314
16
- docent/_llm_util/providers/openai.py,sha256=4niQV9CNaJ-iiEwYG0BSFxCwcsCAWZz0JuUs4wBKu9M,25904
16
+ docent/_llm_util/providers/openai.py,sha256=ebLUMF2-nTniI8OEBqS5sma5cM_LF0igOoWSfVfnWZw,26016
17
17
  docent/_llm_util/providers/openrouter.py,sha256=sT2onpeQ1gAwJLjkQbzD2RodJWTm013Q-siTXezca10,11958
18
18
  docent/_llm_util/providers/preference_types.py,sha256=K1IH15YyU8E8F7Jk7LgLKiCJeDNk9uASTdnZGk5hSDc,3773
19
19
  docent/_llm_util/providers/provider_registry.py,sha256=EPYGQlegYPtg4ogEusCftm_5PZP-_XVKH1qg3xjPFTU,6337
@@ -52,8 +52,8 @@ docent/samples/log.eval,sha256=orrW__9WBfANq7NwKsPSq9oTsQRcG6KohG5tMr_X_XY,39770
52
52
  docent/samples/tb_airline.json,sha256=eR2jFFRtOw06xqbEglh6-dPewjifOk-cuxJq67Dtu5I,47028
53
53
  docent/sdk/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
54
54
  docent/sdk/agent_run_writer.py,sha256=0AWdxejoqZyuj9JSA39WlEwGcMSYTWNqnzIuluySY-M,11043
55
- docent/sdk/client.py,sha256=ZRJDz1RKcV7_gA0zHbr3bIdvUqFrSU99Zes__2kVnKo,19184
56
- docent_python-0.1.23a0.dist-info/METADATA,sha256=sxm-OrFzMKg2U2G_EmrHlGeceqhpY7cGzKa0H989FOo,1351
57
- docent_python-0.1.23a0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
58
- docent_python-0.1.23a0.dist-info/licenses/LICENSE.md,sha256=QIMv2UiT6MppRasso4ymaA0w7ltkqmlL0HCt8CLD7Rc,580
59
- docent_python-0.1.23a0.dist-info/RECORD,,
55
+ docent/sdk/client.py,sha256=aB_ILmzzK9JAC2kobtnp50stfINpSfNh54siaDlMEKc,19880
56
+ docent_python-0.1.25a0.dist-info/METADATA,sha256=kBFVQJ-HqomY9dG6wd3xCw9OyC5gRP7Gz3ZIQHpqq0c,1351
57
+ docent_python-0.1.25a0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
58
+ docent_python-0.1.25a0.dist-info/licenses/LICENSE.md,sha256=QIMv2UiT6MppRasso4ymaA0w7ltkqmlL0HCt8CLD7Rc,580
59
+ docent_python-0.1.25a0.dist-info/RECORD,,