docent-python 0.1.4a0__tar.gz → 0.1.5a0__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.
Files changed (33) hide show
  1. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/PKG-INFO +1 -2
  2. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/sdk/client.py +33 -23
  3. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/trace.py +51 -21
  4. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/pyproject.toml +1 -2
  5. docent_python-0.1.5a0/uv.lock +954 -0
  6. docent_python-0.1.4a0/docent/trace_alt.py +0 -513
  7. docent_python-0.1.4a0/uv.lock +0 -2030
  8. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/.gitignore +0 -0
  9. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/LICENSE.md +0 -0
  10. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/README.md +0 -0
  11. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/__init__.py +0 -0
  12. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/_log_util/__init__.py +0 -0
  13. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/_log_util/logger.py +0 -0
  14. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/data_models/__init__.py +0 -0
  15. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/data_models/_tiktoken_util.py +0 -0
  16. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/data_models/agent_run.py +0 -0
  17. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/data_models/chat/__init__.py +0 -0
  18. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/data_models/chat/content.py +0 -0
  19. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/data_models/chat/message.py +0 -0
  20. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/data_models/chat/tool.py +0 -0
  21. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/data_models/citation.py +0 -0
  22. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/data_models/metadata.py +0 -0
  23. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/data_models/regex.py +0 -0
  24. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/data_models/shared_types.py +0 -0
  25. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/data_models/transcript.py +0 -0
  26. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/loaders/load_inspect.py +0 -0
  27. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/py.typed +0 -0
  28. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/samples/__init__.py +0 -0
  29. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/samples/load.py +0 -0
  30. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/samples/log.eval +0 -0
  31. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/samples/tb_airline.json +0 -0
  32. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/sdk/__init__.py +0 -0
  33. {docent_python-0.1.4a0 → docent_python-0.1.5a0}/docent/trace_temp.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docent-python
3
- Version: 0.1.4a0
3
+ Version: 0.1.5a0
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
@@ -22,4 +22,3 @@ Requires-Dist: pydantic>=2.11.7
22
22
  Requires-Dist: pyyaml>=6.0.2
23
23
  Requires-Dist: tiktoken>=0.7.0
24
24
  Requires-Dist: tqdm>=4.67.1
25
- Requires-Dist: traceloop-sdk>=0.44.1
@@ -197,75 +197,85 @@ class Docent:
197
197
  return response.json()
198
198
 
199
199
  def list_searches(self, collection_id: str) -> list[dict[str, Any]]:
200
- """List all searches for a given collection.
200
+ """List all rubrics for a given collection.
201
201
 
202
202
  Args:
203
203
  collection_id: ID of the Collection.
204
204
 
205
205
  Returns:
206
- list: List of dictionaries containing search query information.
206
+ list: List of dictionaries containing rubric information.
207
207
 
208
208
  Raises:
209
209
  requests.exceptions.HTTPError: If the API request fails.
210
210
  """
211
- url = f"{self._server_url}/{collection_id}/list_search_queries"
211
+ url = f"{self._server_url}/rubric/{collection_id}/rubrics"
212
212
  response = self._session.get(url)
213
213
  response.raise_for_status()
214
214
  return response.json()
215
215
 
216
- def get_search_results(self, collection_id: str, search_query: str) -> list[dict[str, Any]]:
217
- """Get search results for a given collection and search query.
218
- Pass in either search_query or query_id.
216
+ def get_search_results(
217
+ self, collection_id: str, rubric_id: str, rubric_version: int
218
+ ) -> list[dict[str, Any]]:
219
+ """Get rubric results for a given collection, rubric and version.
219
220
 
220
221
  Args:
221
222
  collection_id: ID of the Collection.
222
- search_query: The search query to get results for.
223
+ rubric_id: The ID of the rubric to get results for.
224
+ rubric_version: The version of the rubric to get results for.
223
225
 
224
226
  Returns:
225
- list: List of dictionaries containing search result information.
227
+ list: List of dictionaries containing rubric result information.
226
228
 
227
229
  Raises:
228
230
  requests.exceptions.HTTPError: If the API request fails.
229
231
  """
230
- url = f"{self._server_url}/{collection_id}/get_search_results"
231
- response = self._session.post(url, json={"search_query": search_query})
232
+ url = f"{self._server_url}/rubric/{collection_id}/{rubric_id}/results"
233
+ response = self._session.get(url, params={"rubric_version": rubric_version})
232
234
  response.raise_for_status()
233
235
  return response.json()
234
236
 
235
- def list_search_clusters(self, collection_id: str, search_query: str) -> list[dict[str, Any]]:
236
- """List all search clusters for a given collection.
237
- Pass in either search_query or query_id.
237
+ def list_search_clusters(
238
+ self, collection_id: str, rubric_id: str, rubric_version: int | None = None
239
+ ) -> list[dict[str, Any]]:
240
+ """List all centroids for a given collection and rubric.
238
241
 
239
242
  Args:
240
243
  collection_id: ID of the Collection.
241
- search_query: The search query to get clusters for.
244
+ rubric_id: The ID of the rubric to get centroids for.
245
+ rubric_version: Optional version of the rubric. If not provided, uses latest.
242
246
 
243
247
  Returns:
244
- list: List of dictionaries containing search cluster information.
248
+ list: List of dictionaries containing centroid information.
245
249
 
246
250
  Raises:
247
251
  requests.exceptions.HTTPError: If the API request fails.
248
252
  """
249
- url = f"{self._server_url}/{collection_id}/list_search_clusters"
250
- response = self._session.post(url, json={"search_query": search_query})
253
+ url = f"{self._server_url}/rubric/{collection_id}/{rubric_id}/centroids"
254
+ params: dict[str, int] = {}
255
+ if rubric_version is not None:
256
+ params["rubric_version"] = rubric_version
257
+ response = self._session.get(url, params=params)
251
258
  response.raise_for_status()
252
259
  return response.json()
253
260
 
254
- def get_cluster_matches(self, collection_id: str, centroid: str) -> list[dict[str, Any]]:
255
- """Get the matches for a given cluster.
261
+ def get_cluster_matches(
262
+ self, collection_id: str, rubric_id: str, rubric_version: int
263
+ ) -> list[dict[str, Any]]:
264
+ """Get centroid assignments for a given rubric.
256
265
 
257
266
  Args:
258
267
  collection_id: ID of the Collection.
259
- cluster_id: The ID of the cluster to get matches for.
268
+ rubric_id: The ID of the rubric to get assignments for.
269
+ rubric_version: The version of the rubric to get assignments for.
260
270
 
261
271
  Returns:
262
- list: List of dictionaries containing the search results that match the cluster.
272
+ list: List of dictionaries containing centroid assignment information.
263
273
 
264
274
  Raises:
265
275
  requests.exceptions.HTTPError: If the API request fails.
266
276
  """
267
- url = f"{self._server_url}/{collection_id}/get_cluster_matches"
268
- response = self._session.post(url, json={"centroid": centroid})
277
+ url = f"{self._server_url}/rubric/{collection_id}/{rubric_id}/assignments"
278
+ response = self._session.get(url, params={"rubric_version": rubric_version})
269
279
  response.raise_for_status()
270
280
  return response.json()
271
281
 
@@ -11,7 +11,8 @@ from collections import defaultdict
11
11
  from contextlib import asynccontextmanager, contextmanager
12
12
  from contextvars import ContextVar, Token
13
13
  from datetime import datetime, timezone
14
- from typing import Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Union
14
+ from enum import Enum
15
+ from typing import Any, AsyncIterator, Callable, Dict, Iterator, List, Optional, Set, Union
15
16
 
16
17
  import requests
17
18
  from opentelemetry import trace
@@ -42,6 +43,15 @@ DEFAULT_ENDPOINT = "https://api.docent.transluce.org/rest/telemetry"
42
43
  DEFAULT_COLLECTION_NAME = "default-collection-name"
43
44
 
44
45
 
46
+ class Instruments(Enum):
47
+ """Enumeration of available instrument types."""
48
+
49
+ OPENAI = "openai"
50
+ ANTHROPIC = "anthropic"
51
+ BEDROCK = "bedrock"
52
+ LANGCHAIN = "langchain"
53
+
54
+
45
55
  def _is_notebook() -> bool:
46
56
  """Check if we're running in a Jupyter notebook."""
47
57
  try:
@@ -64,6 +74,8 @@ class DocentTracer:
64
74
  enable_console_export: bool = False,
65
75
  enable_otlp_export: bool = True,
66
76
  disable_batch: bool = False,
77
+ instruments: Optional[Set[Instruments]] = None,
78
+ block_instruments: Optional[Set[Instruments]] = None,
67
79
  ):
68
80
  """
69
81
  Initialize Docent tracing manager.
@@ -78,6 +90,8 @@ class DocentTracer:
78
90
  enable_console_export: Whether to export to console
79
91
  enable_otlp_export: Whether to export to OTLP endpoint
80
92
  disable_batch: Whether to disable batch processing (use SimpleSpanProcessor)
93
+ instruments: Set of instruments to enable (None = all instruments)
94
+ block_instruments: Set of instruments to explicitly disable
81
95
  """
82
96
  self.collection_name: str = collection_name
83
97
  self.collection_id: str = collection_id if collection_id else str(uuid.uuid4())
@@ -105,6 +119,9 @@ class DocentTracer:
105
119
  self.enable_console_export = enable_console_export
106
120
  self.enable_otlp_export = enable_otlp_export
107
121
  self.disable_batch = disable_batch
122
+ self.disabled_instruments: Set[Instruments] = {Instruments.LANGCHAIN}
123
+ self.instruments = instruments or (set(Instruments) - self.disabled_instruments)
124
+ self.block_instruments = block_instruments or set()
108
125
 
109
126
  # Use separate tracer provider to avoid interfering with existing OTEL setup
110
127
  self._tracer_provider: Optional[TracerProvider] = None
@@ -333,33 +350,39 @@ class DocentTracer:
333
350
  except Exception as e:
334
351
  logger.warning(f"Failed to instrument threading: {e}")
335
352
 
353
+ enabled_instruments = self.instruments - self.block_instruments
354
+
336
355
  # Instrument OpenAI with our isolated tracer provider
337
- try:
338
- OpenAIInstrumentor().instrument(tracer_provider=self._tracer_provider)
339
- logger.info("Instrumented OpenAI")
340
- except Exception as e:
341
- logger.warning(f"Failed to instrument OpenAI: {e}")
356
+ if Instruments.OPENAI in enabled_instruments:
357
+ try:
358
+ OpenAIInstrumentor().instrument(tracer_provider=self._tracer_provider)
359
+ logger.info("Instrumented OpenAI")
360
+ except Exception as e:
361
+ logger.warning(f"Failed to instrument OpenAI: {e}")
342
362
 
343
363
  # Instrument Anthropic with our isolated tracer provider
344
- try:
345
- AnthropicInstrumentor().instrument(tracer_provider=self._tracer_provider)
346
- logger.info("Instrumented Anthropic")
347
- except Exception as e:
348
- logger.warning(f"Failed to instrument Anthropic: {e}")
364
+ if Instruments.ANTHROPIC in enabled_instruments:
365
+ try:
366
+ AnthropicInstrumentor().instrument(tracer_provider=self._tracer_provider)
367
+ logger.info("Instrumented Anthropic")
368
+ except Exception as e:
369
+ logger.warning(f"Failed to instrument Anthropic: {e}")
349
370
 
350
371
  # Instrument Bedrock with our isolated tracer provider
351
- try:
352
- BedrockInstrumentor().instrument(tracer_provider=self._tracer_provider)
353
- logger.info("Instrumented Bedrock")
354
- except Exception as e:
355
- logger.warning(f"Failed to instrument Bedrock: {e}")
372
+ if Instruments.BEDROCK in enabled_instruments:
373
+ try:
374
+ BedrockInstrumentor().instrument(tracer_provider=self._tracer_provider)
375
+ logger.info("Instrumented Bedrock")
376
+ except Exception as e:
377
+ logger.warning(f"Failed to instrument Bedrock: {e}")
356
378
 
357
379
  # Instrument LangChain with our isolated tracer provider
358
- try:
359
- LangchainInstrumentor().instrument(tracer_provider=self._tracer_provider)
360
- logger.info("Instrumented LangChain")
361
- except Exception as e:
362
- logger.warning(f"Failed to instrument LangChain: {e}")
380
+ if Instruments.LANGCHAIN in enabled_instruments:
381
+ try:
382
+ LangchainInstrumentor().instrument(tracer_provider=self._tracer_provider)
383
+ logger.info("Instrumented LangChain")
384
+ except Exception as e:
385
+ logger.warning(f"Failed to instrument LangChain: {e}")
363
386
 
364
387
  # Register cleanup handlers
365
388
  self._register_cleanup()
@@ -942,6 +965,8 @@ def initialize_tracing(
942
965
  enable_console_export: bool = False,
943
966
  enable_otlp_export: bool = True,
944
967
  disable_batch: bool = False,
968
+ instruments: Optional[Set[Instruments]] = None,
969
+ block_instruments: Optional[Set[Instruments]] = None,
945
970
  ) -> DocentTracer:
946
971
  """
947
972
  Initialize the global Docent tracer.
@@ -958,6 +983,8 @@ def initialize_tracing(
958
983
  enable_console_export: Whether to export spans to console
959
984
  enable_otlp_export: Whether to export spans to OTLP endpoint
960
985
  disable_batch: Whether to disable batch processing (use SimpleSpanProcessor)
986
+ instruments: Set of instruments to enable (None = all instruments).
987
+ block_instruments: Set of instruments to explicitly disable.
961
988
 
962
989
  Returns:
963
990
  The initialized Docent tracer
@@ -966,6 +993,7 @@ def initialize_tracing(
966
993
  # Basic setup
967
994
  initialize_tracing("my-collection")
968
995
  """
996
+
969
997
  global _global_tracer
970
998
 
971
999
  # Check for API key in environment variable if not provided as parameter
@@ -983,6 +1011,8 @@ def initialize_tracing(
983
1011
  enable_console_export=enable_console_export,
984
1012
  enable_otlp_export=enable_otlp_export,
985
1013
  disable_batch=disable_batch,
1014
+ instruments=instruments,
1015
+ block_instruments=block_instruments,
986
1016
  )
987
1017
  _global_tracer.initialize()
988
1018
 
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "docent-python"
3
3
  description = "Docent SDK"
4
- version = "0.1.4-alpha"
4
+ version = "0.1.5-alpha"
5
5
  authors = [
6
6
  { name="Transluce", email="info@transluce.org" },
7
7
  ]
@@ -25,7 +25,6 @@ dependencies = [
25
25
  "opentelemetry-instrumentation-langchain>=0.44.1",
26
26
  "opentelemetry-instrumentation-openai>=0.44.1",
27
27
  "opentelemetry-instrumentation-threading>=0.55b1",
28
- "traceloop-sdk>=0.44.1",
29
28
  ]
30
29
 
31
30
  [build-system]