22
33import com .embabel .agent .domain .io .UserInput ;
44import com .embabel .agent .testing .unit .FakeOperationContext ;
5+ import com .embabel .agent .testing .unit .FakePromptRunner ;
56import com .embabel .agent .testing .unit .UnitTestUtils ;
67import org .junit .jupiter .api .Test ;
78
@@ -14,12 +15,18 @@ class WriteAndReviewAgentTest {
1415
1516 @ Test
1617 void testWriteAndReviewAgent () {
18+ var context = FakeOperationContext .create ();
19+ var promptRunner = (FakePromptRunner ) context .promptRunner ();
20+ context .expectResponse (new Story ("One upon a time Sir Galahad . . " ));
21+
1722 var agent = new WriteAndReviewAgent (200 , 400 );
18- var llmCall = UnitTestUtils .captureLlmCall (() -> {
19- agent .craftStory (new UserInput ("Tell me a story about a brave knight" , Instant .now ()));
20- });
21- assertTrue (llmCall .getPrompt ().contains ("knight" ), "Expected prompt to contain 'knight'" );
22- assertEquals (0.9 , llmCall .getLlm ().getTemperature (), 0.01 ,
23+ agent .craftStory (new UserInput ("Tell me a story about a brave knight" , Instant .now ()), context );
24+
25+ String prompt = promptRunner .getLlmInvocations ().getFirst ().getPrompt ();
26+ assertTrue (prompt .contains ("knight" ), "Expected prompt to contain 'knight'" );
27+
28+ var temp = promptRunner .getLlmInvocations ().getFirst ().getInteraction ().getLlm ().getTemperature ();
29+ assertEquals (0.9 , temp , 0.01 ,
2330 "Expected temperature to be 0.9: Higher for more creative output" );
2431 }
2532
0 commit comments