Skip to main content

digline-anthropic

An Anthropic target and judges for digline: a prompt file goes in, a priced Response comes out.

pip install digline-anthropic

Requires Python 3.12+, like digline itself.

from pathlib import Path
from digline_anthropic import AnthropicTarget

target = AnthropicTarget(
    prompt_file=Path(__file__).parent / "prompts/answer.md",
    system_file=Path(__file__).parent / "prompts/system.md",
    model="claude-sonnet-5",
    max_tokens=1024,
    prefill="{",  # put JSON in the model's mouth
)

Both files are recorded in every run, so the committed baseline carries the prompt that produced it. Cost comes from a price list declared in code and replaceable in one argument; an unknown model raises rather than costing nothing. The key is never named here — the SDK reads ANTHROPIC_API_KEY.

The judges

A plugin is a target and a judge (ADR 0004): whoever generates can judge, with the same key and the same price list, and the twenty lines of SDK-and-JSON leave your suite.

from digline.core import LlmRubric
from digline_anthropic import AnthropicJudge

judge = AnthropicJudge(model="claude-haiku-4-5")
rubric = LlmRubric(
    rubric="The answer is one sentence and cites the passage it came from.",
    judge=judge,
    threshold=0.8,
    tolerance=0.05,
)

Faithfulness asks a judge to decompose rather than to score — how many claims the output makes, how many the context supports — so it takes the other one:

from digline.core import Faithfulness
from digline_anthropic import AnthropicClaimJudge

faithful = Faithfulness(
    judge=AnthropicClaimJudge(model="claude-haiku-4-5"),
    threshold=0.9,
    tolerance=0.05,
)

A model that thinks before it answers needs a larger max_tokens. max_tokens defaults to 400, enough for the object a judge is asked for. A model that thinks before it answers spends its thinking out of the same allowance, and when the thinking fills it every judging call is cut before the first character. The verdict says so, with the provider's own reason and the remedy: "the judge returned no text: the provider reported 'max_tokens' (600 of 600 output tokens) … raise max_tokens". In the run reported in #599, with claude-opus-5, every call was cut at 600 and judged normally at 16000. Raise it where the judge is built, AnthropicJudge(model="claude-opus-5", max_tokens=16000), and the same for AnthropicClaimJudge. A judge given by coordinates in a TOML suite takes the plugin's defaults and cannot be given another max_tokens, so a TOML suite that judges with such a model moves its judge into a suite.py (docs/declarative.md, The judge, by coordinates).

Both put { in the model's mouth and prepend it before parsing, and both read a reply the model wrapped in a fence or a sentence. What judging cost is counted on the judge and never reset:

from digline_anthropic import AnthropicJudge

judge = AnthropicJudge(model="claude-haiku-4-5")
print(f"{judge.calls} judgements, {judge.spent_usd:.4f} USD, {judge.latency_ms:.0f} ms")

A suite with samples=5 and Repeated(n=3) makes fifteen judging calls per case, so this is not a rounding error. For a per-run figure, read it before and after and subtract. It is in-process only today, and ADR 0004 §3 says what it would take to put it in the report.

Apache-2.0. Docs: digline/digline.

Metadata

Release files for digline-anthropic 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for digline-anthropic 0.8.0
File Size Uploaded Provenance Actions
digline_anthropic-0.8.0.tar.gz 33.2 kB With provenance Details for digline_anthropic-0.8.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for digline-anthropic 0.8.0
File Interpreter ABI Platform Actions
digline_anthropic-0.8.0-py3-none-any.whl Python 3 none any Details for digline_anthropic-0.8.0-py3-none-any.whl

Total release size: 52.1 kB

Release files / digline_anthropic-0.8.0.tar.gz

Download URL digline_anthropic-0.8.0.tar.gz
Size 33.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ee014a19ae8d4ccb89e711131f6bba546b9480616644a103f0af71fe5199e906
BLAKE2b-256 checksum
How to use checksums
c32da90b9b96ca1bf92d1ed8ef7e09e943cb5db668d8e5293838488a170625c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Release files / digline_anthropic-0.8.0-py3-none-any.whl

Download URL digline_anthropic-0.8.0-py3-none-any.whl
Size 18.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2be35ee25fbf31fc51d74238c17242e9e447d1bc2d8353539dad4f415ecf3156
BLAKE2b-256 checksum
How to use checksums
69f21cde3dcc27641be877b8382c46b4ad87ea32b621300f001f1e699a25fc89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

Security for digline-anthropic 0.8.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for digline_anthropic-0.8.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page