docent-python 0.1.46a0__tar.gz → 0.1.47a0__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 (68) hide show
  1. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/PKG-INFO +1 -1
  2. docent_python-0.1.47a0/docent/sdk/__init__.py +5 -0
  3. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/sdk/client.py +109 -1
  4. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/pyproject.toml +1 -1
  5. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/uv.lock +1 -1
  6. docent_python-0.1.46a0/docent/sdk/__init__.py +0 -0
  7. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/.gitignore +0 -0
  8. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/LICENSE.md +0 -0
  9. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/README.md +0 -0
  10. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/__init__.py +0 -0
  11. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/__init__.py +0 -0
  12. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/data_models/__init__.py +0 -0
  13. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/data_models/exceptions.py +0 -0
  14. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/data_models/llm_output.py +0 -0
  15. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/llm_cache.py +0 -0
  16. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/llm_svc.py +0 -0
  17. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/model_registry.py +0 -0
  18. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/__init__.py +0 -0
  19. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/anthropic.py +0 -0
  20. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/common.py +0 -0
  21. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/google.py +0 -0
  22. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/openai.py +0 -0
  23. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/openrouter.py +0 -0
  24. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/preference_types.py +0 -0
  25. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/provider_registry.py +0 -0
  26. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_log_util/__init__.py +0 -0
  27. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_log_util/logger.py +0 -0
  28. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/__init__.py +0 -0
  29. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/_tiktoken_util.py +0 -0
  30. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/agent_run.py +0 -0
  31. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/chat/__init__.py +0 -0
  32. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/chat/content.py +0 -0
  33. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/chat/message.py +0 -0
  34. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/chat/response_format.py +0 -0
  35. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/chat/tool.py +0 -0
  36. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/citation.py +0 -0
  37. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/formatted_objects.py +0 -0
  38. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/judge.py +0 -0
  39. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/metadata_util.py +0 -0
  40. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/regex.py +0 -0
  41. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/transcript.py +0 -0
  42. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/util.py +0 -0
  43. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/__init__.py +0 -0
  44. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/analysis.py +0 -0
  45. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/impl.py +0 -0
  46. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/runner.py +0 -0
  47. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/stats.py +0 -0
  48. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/types.py +0 -0
  49. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/util/forgiving_json.py +0 -0
  50. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/util/meta_schema.json +0 -0
  51. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/util/meta_schema.py +0 -0
  52. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/util/parse_output.py +0 -0
  53. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/util/template_formatter.py +0 -0
  54. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/util/voting.py +0 -0
  55. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/loaders/load_inspect.py +0 -0
  56. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/mcp/__init__.py +0 -0
  57. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/mcp/__main__.py +0 -0
  58. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/mcp/server.py +0 -0
  59. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/py.typed +0 -0
  60. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/samples/__init__.py +0 -0
  61. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/samples/load.py +0 -0
  62. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/samples/log.eval +0 -0
  63. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/samples/tb_airline.json +0 -0
  64. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/sdk/agent_run_writer.py +0 -0
  65. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/sdk/llm_context.py +0 -0
  66. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/sdk/llm_request.py +0 -0
  67. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/trace.py +0 -0
  68. {docent_python-0.1.46a0 → docent_python-0.1.47a0}/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.46a0
3
+ Version: 0.1.47a0
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
@@ -0,0 +1,5 @@
1
+ from docent.judges.impl import BaseJudge
2
+ from docent.judges.types import Rubric
3
+ from docent.sdk.client import Docent
4
+
5
+ __all__ = ["BaseJudge", "Rubric", "Docent"]
@@ -5,7 +5,11 @@ import time
5
5
  import webbrowser
6
6
  from itertools import islice
7
7
  from pathlib import Path
8
- from typing import IO, Any, Iterable, Iterator, Literal, TypeVar, cast
8
+ from typing import IO, TYPE_CHECKING, Any, Iterable, Iterator, Literal, TypeVar, cast
9
+
10
+ if TYPE_CHECKING:
11
+ from docent.judges.impl import BaseJudge
12
+ from docent.judges.types import Rubric
9
13
 
10
14
  import pandas as pd
11
15
  import requests
@@ -581,6 +585,110 @@ class Docent:
581
585
  self._handle_response_errors(response)
582
586
  return response.json()
583
587
 
588
+ def create_rubric(
589
+ self,
590
+ collection_id: str,
591
+ rubric: "Rubric",
592
+ ) -> str:
593
+ """Create a new rubric in a collection.
594
+
595
+ Args:
596
+ collection_id: ID of the Collection.
597
+ rubric: The Rubric configuration to create. Must have version=1.
598
+
599
+ Returns:
600
+ str: The ID of the created rubric.
601
+
602
+ Raises:
603
+ requests.exceptions.HTTPError: If the API request fails.
604
+ ValueError: If rubric.version != 1.
605
+
606
+ Example:
607
+ >>> from docent.sdk import Docent, Rubric
608
+ >>> client = Docent(api_key="...")
609
+ >>> rubric = Rubric(
610
+ ... rubric_text="Judge whether the agent completed the task...",
611
+ ... output_schema={
612
+ ... "type": "object",
613
+ ... "properties": {
614
+ ... "label": {"type": "string", "enum": ["pass", "fail"]},
615
+ ... "explanation": {"type": "string"},
616
+ ... },
617
+ ... "required": ["label", "explanation"],
618
+ ... },
619
+ ... )
620
+ >>> rubric_id = client.create_rubric(collection_id, rubric)
621
+ """
622
+ url = f"{self._server_url}/rubric/{collection_id}/rubric"
623
+ payload = {"rubric": rubric.model_dump(mode="json")}
624
+ response = self._session.post(url, json=payload)
625
+ self._handle_response_errors(response)
626
+ return response.json()
627
+
628
+ def get_rubric(
629
+ self,
630
+ collection_id: str,
631
+ rubric_id: str,
632
+ version: int | None = None,
633
+ ) -> "Rubric":
634
+ """Get a rubric configuration by ID.
635
+
636
+ Args:
637
+ collection_id: ID of the Collection.
638
+ rubric_id: ID of the rubric to retrieve.
639
+ version: Optional version number. If None, returns latest version.
640
+
641
+ Returns:
642
+ Rubric: The rubric configuration object.
643
+
644
+ Raises:
645
+ requests.exceptions.HTTPError: If the API request fails.
646
+ """
647
+ from docent.judges.types import Rubric
648
+
649
+ url = f"{self._server_url}/rubric/{collection_id}/rubric/{rubric_id}"
650
+ params = {"version": version} if version is not None else None
651
+ response = self._session.get(url, params=params)
652
+ self._handle_response_errors(response)
653
+ return Rubric.model_validate(response.json())
654
+
655
+ def get_judge(
656
+ self,
657
+ collection_id: str,
658
+ rubric_id: str,
659
+ version: int | None = None,
660
+ ) -> "BaseJudge":
661
+ """Get a ready-to-use judge by rubric ID.
662
+
663
+ Downloads the rubric configuration and creates a callable judge.
664
+ API keys are read from environment variables (OPENAI_API_KEY,
665
+ ANTHROPIC_API_KEY, etc.) based on the rubric's configured provider.
666
+
667
+ Args:
668
+ collection_id: ID of the Collection.
669
+ rubric_id: ID of the rubric/judge to retrieve.
670
+ version: Optional version number. If None, returns latest version.
671
+
672
+ Returns:
673
+ BaseJudge: A callable judge. Use `await judge(agent_run)` to run.
674
+
675
+ Raises:
676
+ requests.exceptions.HTTPError: If the API request fails.
677
+
678
+ Example:
679
+ >>> judge = client.get_judge(collection_id, rubric_id)
680
+ >>> # Inspect the config
681
+ >>> print(judge.cfg.rubric_text)
682
+ >>> # Run locally (async)
683
+ >>> result = await judge(agent_run)
684
+ """
685
+ from docent._llm_util.llm_svc import BaseLLMService
686
+ from docent.judges.impl import build_judge
687
+
688
+ rubric = self.get_rubric(collection_id, rubric_id, version)
689
+ llm_svc = BaseLLMService() # reads API keys from environment
690
+ return build_judge(rubric, llm_svc)
691
+
584
692
  def get_rubric_run_state(
585
693
  self,
586
694
  collection_id: str,
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "docent-python"
3
3
  description = "Docent SDK"
4
- version = "0.1.46-alpha"
4
+ version = "0.1.47-alpha"
5
5
  authors = [
6
6
  { name="Transluce", email="info@transluce.org" },
7
7
  ]
@@ -556,7 +556,7 @@ wheels = [
556
556
 
557
557
  [[package]]
558
558
  name = "docent-python"
559
- version = "0.1.45a0"
559
+ version = "0.1.46a0"
560
560
  source = { editable = "." }
561
561
  dependencies = [
562
562
  { name = "anthropic" },
File without changes