docent-python 0.1.31a0__tar.gz → 0.1.33a0__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 (62) hide show
  1. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/PKG-INFO +1 -1
  2. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/__init__.py +2 -0
  3. docent_python-0.1.33a0/docent/data_models/collection.py +23 -0
  4. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/sdk/client.py +25 -3
  5. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/trace.py +14 -7
  6. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/pyproject.toml +1 -1
  7. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/.gitignore +0 -0
  8. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/LICENSE.md +0 -0
  9. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/README.md +0 -0
  10. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/__init__.py +0 -0
  11. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/__init__.py +0 -0
  12. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/data_models/__init__.py +0 -0
  13. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/data_models/exceptions.py +0 -0
  14. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/data_models/llm_output.py +0 -0
  15. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/llm_cache.py +0 -0
  16. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/llm_svc.py +0 -0
  17. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/model_registry.py +0 -0
  18. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/providers/__init__.py +0 -0
  19. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/providers/anthropic.py +0 -0
  20. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/providers/common.py +0 -0
  21. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/providers/google.py +0 -0
  22. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/providers/openai.py +0 -0
  23. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/providers/openrouter.py +0 -0
  24. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/providers/preference_types.py +0 -0
  25. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_llm_util/providers/provider_registry.py +0 -0
  26. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_log_util/__init__.py +0 -0
  27. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/_log_util/logger.py +0 -0
  28. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/_tiktoken_util.py +0 -0
  29. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/agent_run.py +0 -0
  30. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/chat/__init__.py +0 -0
  31. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/chat/content.py +0 -0
  32. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/chat/message.py +0 -0
  33. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/chat/tool.py +0 -0
  34. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/citation.py +0 -0
  35. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/judge.py +0 -0
  36. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/metadata_util.py +0 -0
  37. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/regex.py +0 -0
  38. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/remove_invalid_citation_ranges.py +0 -0
  39. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/shared_types.py +0 -0
  40. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/transcript.py +0 -0
  41. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/data_models/util.py +0 -0
  42. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/judges/__init__.py +0 -0
  43. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/judges/analysis.py +0 -0
  44. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/judges/impl.py +0 -0
  45. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/judges/runner.py +0 -0
  46. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/judges/stats.py +0 -0
  47. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/judges/types.py +0 -0
  48. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/judges/util/forgiving_json.py +0 -0
  49. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/judges/util/meta_schema.json +0 -0
  50. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/judges/util/meta_schema.py +0 -0
  51. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/judges/util/parse_output.py +0 -0
  52. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/judges/util/voting.py +0 -0
  53. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/loaders/load_inspect.py +0 -0
  54. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/py.typed +0 -0
  55. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/samples/__init__.py +0 -0
  56. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/samples/load.py +0 -0
  57. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/samples/log.eval +0 -0
  58. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/samples/tb_airline.json +0 -0
  59. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/sdk/__init__.py +0 -0
  60. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/sdk/agent_run_writer.py +0 -0
  61. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/docent/trace_temp.py +0 -0
  62. {docent_python-0.1.31a0 → docent_python-0.1.33a0}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: docent-python
3
- Version: 0.1.31a0
3
+ Version: 0.1.33a0
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,5 +1,6 @@
1
1
  from docent.data_models.agent_run import AgentRun
2
2
  from docent.data_models.citation import Citation
3
+ from docent.data_models.collection import Collection
3
4
  from docent.data_models.judge import Label
4
5
  from docent.data_models.regex import RegexSnippet
5
6
  from docent.data_models.transcript import Transcript, TranscriptGroup
@@ -7,6 +8,7 @@ from docent.data_models.transcript import Transcript, TranscriptGroup
7
8
  __all__ = [
8
9
  "AgentRun",
9
10
  "Citation",
11
+ "Collection",
10
12
  "Label",
11
13
  "RegexSnippet",
12
14
  "Transcript",
@@ -0,0 +1,23 @@
1
+ from datetime import datetime
2
+
3
+ from pydantic import BaseModel
4
+
5
+
6
+ class Collection(BaseModel):
7
+ """Represents a collection of agent runs.
8
+
9
+ A Collection is a container for organizing and managing related agent runs.
10
+
11
+ Attributes:
12
+ id: Unique identifier for the collection.
13
+ name: Human-readable name for the collection.
14
+ description: Optional description of the collection's purpose.
15
+ created_by: User ID of the collection creator (if available).
16
+ created_at: Timestamp when the collection was created.
17
+ """
18
+
19
+ id: str
20
+ name: str | None = None
21
+ description: str | None = None
22
+ created_by: str | None = None
23
+ created_at: datetime
@@ -8,6 +8,7 @@ from tqdm import tqdm
8
8
 
9
9
  from docent._log_util.logger import get_logger
10
10
  from docent.data_models.agent_run import AgentRun
11
+ from docent.data_models.collection import Collection
11
12
  from docent.data_models.judge import Label
12
13
  from docent.judges.util.meta_schema import validate_judge_result_schema
13
14
  from docent.loaders import load_inspect
@@ -188,11 +189,11 @@ class Docent:
188
189
  logger.info(f"Successfully added {total_runs} agent runs to Collection '{collection_id}'")
189
190
  return {"status": "success", "total_runs_added": total_runs}
190
191
 
191
- def list_collections(self) -> list[dict[str, Any]]:
192
+ def list_collections(self) -> list[Collection]:
192
193
  """Lists all available Collections.
193
194
 
194
195
  Returns:
195
- list: List of dictionaries containing Collection information.
196
+ list: List of Collection objects.
196
197
 
197
198
  Raises:
198
199
  requests.exceptions.HTTPError: If the API request fails.
@@ -200,7 +201,28 @@ class Docent:
200
201
  url = f"{self._server_url}/collections"
201
202
  response = self._session.get(url)
202
203
  self._handle_response_errors(response)
203
- return response.json()
204
+ return [Collection.model_validate(c) for c in response.json()]
205
+
206
+ def get_collection(self, collection_id: str) -> Collection | None:
207
+ """Get details about a specific Collection.
208
+
209
+ Requires READ permission on the collection.
210
+
211
+ Args:
212
+ collection_id: ID of the Collection to retrieve.
213
+
214
+ Returns:
215
+ Collection: Collection object with id, name, description, created_at, and created_by.
216
+ Returns None if collection not found.
217
+
218
+ Raises:
219
+ requests.exceptions.HTTPError: If the API request fails.
220
+ """
221
+ url = f"{self._server_url}/{collection_id}/collection_details"
222
+ response = self._session.get(url)
223
+ self._handle_response_errors(response)
224
+ data = response.json()
225
+ return Collection.model_validate(data) if data is not None else None
204
226
 
205
227
  def list_rubrics(self, collection_id: str) -> list[dict[str, Any]]:
206
228
  """List all rubrics for a given collection.
@@ -44,6 +44,7 @@ from opentelemetry.sdk.trace.export import (
44
44
  )
45
45
  from opentelemetry.trace import Span
46
46
  from requests import Response
47
+
47
48
  from docent._log_util import get_logger
48
49
 
49
50
  logger = get_logger(__name__)
@@ -1676,23 +1677,29 @@ def is_package_installed(package_name: str) -> bool:
1676
1677
  return package_name.lower() in installed_packages
1677
1678
 
1678
1679
 
1679
- def get_tracer(caller: str = "get_tracer()") -> Optional[DocentTracer]:
1680
+ def get_tracer(
1681
+ caller: str = "get_tracer()", log_error_if_tracer_is_none: bool = True
1682
+ ) -> Optional[DocentTracer]:
1680
1683
  """
1681
1684
  Get the global Docent tracer if it has been initialized.
1682
1685
 
1683
1686
  Args:
1684
1687
  caller: Human-readable name of the API being invoked. Used for log output.
1688
+ log_error_if_tracer_is_none: Whether to log an error if the tracer is None.
1689
+ NOTE(mengk): when get_tracer is called in is_disabled, I don't want an error logged,
1690
+ since that's what I'm trying to check. In other contexts, it makes sense.
1685
1691
 
1686
1692
  Returns:
1687
1693
  The global Docent tracer, or None if tracing has not been initialized.
1688
1694
  """
1689
1695
  tracer = _global_tracer
1690
1696
  if tracer is None:
1691
- logger.error(
1692
- f"{caller} requires initialize_tracing() to be called before use. "
1693
- "You can also disable tracing by calling set_disabled(True) or by setting "
1694
- "the DOCENT_DISABLE_TRACING environment variable to 'true'."
1695
- )
1697
+ if log_error_if_tracer_is_none:
1698
+ logger.error(
1699
+ f"{caller} requires initialize_tracing() to be called before use. "
1700
+ "You can also disable tracing by calling set_disabled(True) or by setting "
1701
+ "the DOCENT_DISABLE_TRACING environment variable to 'true'."
1702
+ )
1696
1703
  return None
1697
1704
 
1698
1705
  if not tracer.is_initialized():
@@ -1743,7 +1750,7 @@ def is_disabled(context_name: str = "Docent tracing") -> bool:
1743
1750
  """
1744
1751
  if _global_tracing_disabled:
1745
1752
  return True
1746
- tracer = get_tracer(context_name)
1753
+ tracer = get_tracer(context_name, log_error_if_tracer_is_none=False)
1747
1754
  if tracer is None:
1748
1755
  return True
1749
1756
  return tracer.is_disabled()
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "docent-python"
3
3
  description = "Docent SDK"
4
- version = "0.1.31-alpha"
4
+ version = "0.1.33-alpha"
5
5
  authors = [
6
6
  { name="Transluce", email="info@transluce.org" },
7
7
  ]