File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 ()
You can’t perform that action at this time.
0 commit comments