Skip to main content

fabricatio-judge

MIT Python Versions PyPI Version PyPI Downloads PyPI Downloads Build Tool: uv

Structured, evidence-based binary judgment for LLM applications.

Installation

pip install fabricatio[judge]
# or
uv pip install fabricatio[judge]

Overview

fabricatio-judge provides capability mixins that turn any Fabricatio agent into a structured judge. Instead of raw LLM calls that return arbitrary text, judgments produce typed JudgeMent objects — capturing the issue, affirmative and denying evidence, and a final boolean verdict — so downstream code can act on a reliable, machine-readable result.

Two judgment strategies are available:

  • Single-judge (EvidentlyJudge): one LLM evaluates the prompt and returns a JudgeMent.
  • Weighted voting (VoteJudge): multiple LLM configurations each produce a JudgeMent; their boolean verdicts are weighted and tallied against a configurable pass threshold.

Key Types

Class Role
JudgeMent Pydantic model holding issue_to_judge, affirm_evidence, deny_evidence, and final_judgement. Truthy via __bool__.
EvidentlyJudge ABC mixin (extends Propose). Adds evidently_judge(prompt, **kwargs).
VoteLLMConfig Config model (extends ScopedConfig). Declares vote_llm (weight → kwargs map) and vote_pass_threshold.
VoteJudge ABC mixin (extends EvidentlyJudge + VoteLLMConfig). Adds vote_judge(prompt, ...) and resolve_pass(…).

JudgeMent

class JudgeMent(SketchedAble):
    issue_to_judge: str          # The question or statement under evaluation
    affirm_evidence: List[str]   # Evidence supporting a True verdict
    deny_evidence: List[str]     # Evidence supporting a False verdict
    final_judgement: bool        # The binary verdict

EvidentlyJudge

class EvidentlyJudge(Propose, ABC):
    async def evidently_judge(
        self, prompt: str | List[str], **kwargs
    ) -> JudgeMent | List[JudgeMent] | None

Accepts a single prompt (returns JudgeMent | None) or a list (returns List[JudgeMent | None]). Delegates to the agent's propose infrastructure, which invokes the configured LLM with structured output constrained to the JudgeMent schema.

VoteJudge

class VoteJudge(EvidentlyJudge, VoteLLMConfig, ABC):
    async def vote_judge(
        self, prompt: str | List[str],
        vote_pass_threshold: float | None = None, **kwargs
    ) -> bool | List[bool | None] | None

    @staticmethod
    def resolve_pass(
        weights: List[float],
        judgments: List[JudgeMent],
        vote_pass_threshold: float,
    ) -> bool

vote_judge runs evidently_judge concurrently across all configured LLM weights for each prompt, then calls resolve_pass to determine the final boolean. The pass criterion:

sum(weight[i] for i where judgment[i] is True) >= threshold * sum(all weights)

If any individual judgment returns None, the vote is treated as False with a warning.

Usage

Single-judge

from fabricatio_judge.capabilities.advanced_judge import EvidentlyJudge
from fabricatio_judge.models.judgement import JudgeMent


class MyAgent(EvidentlyJudge):
    """Agent that can judge evidence."""
    pass


async def main():
    agent = MyAgent()
    result: JudgeMent = await agent.evidently_judge("Is the PR safe to merge?")
    if result:
        print(f"Approved — evidence: {result.affirm_evidence}")
    else:
        print(f"Blocked — concerns: {result.deny_evidence}")

Weighted voting

from fabricatio_judge.capabilities.advanced_judge import VoteJudge
from fabricatio_judge.models.judgement import JudgeMent
from fabricatio_core.models.kwargs_types import ValidateKwargs
from typing import Dict


class MyVoter(VoteJudge):
    vote_llm: Dict[float, ValidateKwargs[JudgeMent]] = {
        0.5: {"temperature": 0.3},   # conservative
        0.7: {"temperature": 0.7},   # balanced
        0.9: {"temperature": 1.0},   # creative
    }
    vote_pass_threshold: float = 0.5


async def main():
    voter = MyVoter()
    passed = await voter.vote_judge("Should we deploy to production?")
    print(f"Deploy decision: {passed}")

    # Multiple prompts at once
    results = await voter.vote_judge([
        "Is service A healthy?",
        "Is service B healthy?",
    ])
    # results → [True, False]

Package Structure

fabricatio-judge/
├── python/fabricatio_judge/
│   ├── capabilities/
│   │   └── advanced_judge.py   # EvidentlyJudge, VoteJudge, VoteLLMConfig
│   └── models/
│       └── judgement.py        # JudgeMent
└── python/tests/
    └── test_judge.py

License

MIT — see LICENSE

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fabricatio_judge-0.2.1-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file fabricatio_judge-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: fabricatio_judge-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for fabricatio_judge-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5d7720f628383389b2ecef68730930cedf959cabfcdcf8b4f33a0362536d3607
MD5 8f9904836edc45dd2cf8dc6ab8113d8b
BLAKE2b-256 0386e29d7d6f8ccae8623e457f4b6f91c0f8738ce0c34c7f9fb7b4229e4053dc

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.2

1 file

This release

0.2.1 This release

1 file

0.2.0

1 file

0.1.13

1 file

0.1.12

1 file

0.1.11

1 file

0.1.10

1 file

0.1.9

1 file

0.1.8

1 file

0.1.7

1 file

0.1.6

1 file

0.1.4

1 file

0.1.3

1 file

0.1.2

1 file

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page