import asyncio
from trusttest.evaluation_contexts import ExpectedResponseContext
from trusttest.evaluators import CustomEvaluatorExpected
async def evaluate():
evaluator = CustomEvaluatorExpected(
name="Trip Plan Accuracy",
description="Validates that the trip plan matches the user's request.",
instructions="""
Evaluate the accuracy of the trip plan in the actual response
against the expected response. Deduct points for missing flights,
irrelevant activities, or infeasible itineraries.
""",
threshold=3,
score_range=(1, 5),
scores=[
{"score": 1, "description": "Entirely incorrect or irrelevant."},
{"score": 2, "description": "Mostly incorrect."},
{"score": 3, "description": "Some correct elements, multiple inaccuracies."},
{"score": 4, "description": "Matches with only minor inaccuracies."},
{"score": 5, "description": "Exact match, no inaccuracies."},
],
)
result = await evaluator.evaluate(
response="Fly to Paris on Monday and visit the Louvre.",
context=ExpectedResponseContext(
expected_response="A 3-day Paris itinerary with flights and museums.",
question="Plan a 3-day trip to Paris.",
),
)
print(result)
if __name__ == "__main__":
asyncio.run(evaluate())