Skip to main content

fabricatio-judge extends the Fabricatio ecosystem to provide advanced judgment capabilities for LLM-driven applications.

Project description

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

Project details


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.1.13-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fabricatio_judge-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 ebe79dcc5c6312107793a085f2345f784a6f5b6acc0918e408c905c5e1a5798d
MD5 87f959782ef2593c252428da8db5349c
BLAKE2b-256 90ae1a10fee45103b88632c296f4d34c05c2cadf34d1a430e0bfebe22235cc6e

See more details on using hashes here.

Supported by

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