Skip to content

Commit aa46eb6

Browse files
committed
fix(example): restore basic evaluation example
1 parent 08d2f9e commit aa46eb6

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from agentunit import Evaluation, Task
2+
3+
4+
class FakeAdapter:
5+
def __init__(self, response: str):
6+
self.response = response
7+
8+
def run(self, prompt: str) -> str:
9+
return self.response
10+
11+
12+
def main():
13+
# define simple task
14+
# each task specifies a prompt and expected output
15+
task = Task(name="echo-task", prompt="Say hello", expected="hello")
16+
# create a fake model adapter that always outputs "hello"
17+
fake_model = FakeAdapter(response="hello")
18+
19+
# build the evaluation
20+
evaluation = Evaluation(task=[task], model=fake_model)
21+
# results can be inspected/printed
22+
results = evaluation.run()
23+
24+
# print a readable summary
25+
print("=== Evaluation Summary ===")
26+
for result in results:
27+
print(f"Task: {result.task.name}")
28+
print(f"Prompt: {result.task.prompt}")
29+
print(f"Model Output: {result.output}")
30+
print(f"Expected: {result.task.expected}")
31+
print(f"Passed: {result.passed}")
32+
print("-" * 30)
33+
if __name__ == "__main__":
34+
main()

0 commit comments

Comments
 (0)