from typing import Literal
from agno.agent import Agent
from agno.models.google import Gemini
from pydantic import BaseModel, Field
class Preference(BaseModel):
winner: Literal["A", "B", "tie"] = Field(
..., description="Which response is better, or 'tie' if equal"
)
agent = Agent(
model=Gemini(id="gemini-3.5-flash"),
instructions=(
"Decide which response better answers the prompt. Return 'A', 'B', "
"or 'tie'. Use 'tie' only when the two are genuinely "
"indistinguishable in quality."
),
output_schema=Preference,
)
def build_input(prompt: str, a: str, b: str) -> str:
return f"Prompt:\n{prompt}\n\nResponse A:\n{a}\n\nResponse B:\n{b}"
prompt = "Explain why the sky is blue, in one sentence."
a = "Shorter blue wavelengths scatter more off air molecules, so the sky looks blue."
b = "Because of physics."
result = agent.run(build_input(prompt, a, b)).content
# Preference(winner='A')