Score an agent

Ask, then mark

Pass an agent and the question. The judge runs the agent, then scores what it returned.

input is the question. expected is the answer you want. The agent is who produces the output.

Example

from praisonai import Agent
from praisonai.eval import Judge

agent = Agent(instructions="Answer with a number only.")
result = Judge().run(
    agent=agent,
    input="What is 2+2?",
    expected="4",
)
print("Score:", result.score)
print("Passed:", result.passed)

Try it Yourself

Example explained

  • agent — The agent the judge will run.
  • input — The question sent to that agent.

Format in expected

Expected can include shape, not just facts — fail runs that ignore instructions.

Example

from praisonai import Agent
from praisonai.eval import Judge

agent = Agent(instructions="Reply with one digit.")
result = Judge().run(agent=agent, input="What is 2+2?", expected="4")
print("Passed:", result.passed)

Try it Yourself

Example explained

  • from praisonai import Agent — Imports Agent needed for format in expected.
  • from praisonai.eval import Judge — Imports Judge needed for format in expected.
  • Agent(…) — Instantiates the Agent configured for format in expected.
  • Judge(…) — Scores an agent reply against explicit quality criteria.

Reference: documentation