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.
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/PKG-INFO +1 -1
- docent_python-0.1.47a0/docent/sdk/__init__.py +5 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/sdk/client.py +109 -1
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/pyproject.toml +1 -1
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/uv.lock +1 -1
- docent_python-0.1.46a0/docent/sdk/__init__.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/.gitignore +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/LICENSE.md +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/README.md +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/__init__.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/__init__.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/data_models/__init__.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/data_models/exceptions.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/data_models/llm_output.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/llm_cache.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/llm_svc.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/model_registry.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/__init__.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/anthropic.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/common.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/google.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/openai.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/openrouter.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/preference_types.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/provider_registry.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_log_util/__init__.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_log_util/logger.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/__init__.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/_tiktoken_util.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/agent_run.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/chat/__init__.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/chat/content.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/chat/message.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/chat/response_format.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/chat/tool.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/citation.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/formatted_objects.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/judge.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/metadata_util.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/regex.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/transcript.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/util.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/__init__.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/analysis.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/impl.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/runner.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/stats.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/types.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/util/forgiving_json.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/util/meta_schema.json +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/util/meta_schema.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/util/parse_output.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/util/template_formatter.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/judges/util/voting.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/loaders/load_inspect.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/mcp/__init__.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/mcp/__main__.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/mcp/server.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/py.typed +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/samples/__init__.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/samples/load.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/samples/log.eval +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/samples/tb_airline.json +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/sdk/agent_run_writer.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/sdk/llm_context.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/sdk/llm_request.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/trace.py +0 -0
- {docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/trace_temp.py +0 -0
|
@@ -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,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/data_models/exceptions.py
RENAMED
|
File without changes
|
{docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/data_models/llm_output.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/preference_types.py
RENAMED
|
File without changes
|
{docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/_llm_util/providers/provider_registry.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{docent_python-0.1.46a0 → docent_python-0.1.47a0}/docent/data_models/chat/response_format.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|