@@ -35,19 +35,19 @@ public Response<AiMessage> execute( Map<String,Object> inputs ) {
35
35
}
36
36
37
37
private PromptTemplate getToolResponseTemplate ( ) {
38
- var TEMPLATE_TOOL_RESPONSE = new StringBuilder ()
39
- .append ("TOOL RESPONSE:" ).append ('\n' )
40
- .append ("---------------------" ).append ('\n' )
41
- .append ("{{observation}}" ).append ('\n' )
42
- .append ( "--------------------" ).append ('\n' )
43
- .append ('\n' )
44
- .toString ();
38
+ var TEMPLATE_TOOL_RESPONSE = """
39
+ TOOL RESPONSE:
40
+ ---------------------
41
+ {{observation}}
42
+ --------------------
43
+ """ ;
45
44
return PromptTemplate .from (TEMPLATE_TOOL_RESPONSE );
46
45
}
47
46
48
47
public Response <AiMessage > execute ( String input , List <AgentExecutor .IntermediateStep > intermediateSteps ) {
49
48
var agentScratchpadTemplate = getToolResponseTemplate ();
50
- var userMessageTemplate = PromptTemplate .from ( "USER'S INPUT: {{input}}" ).apply ( Map .of ( "input" , input ));
49
+ var userMessageTemplate = PromptTemplate .from ( "USER'S INPUT: {{input}}" )
50
+ .apply ( Map .of ( "input" , input ));
51
51
52
52
var messages = new ArrayList <ChatMessage >();
53
53
@@ -58,9 +58,9 @@ public Response<AiMessage> execute( String input, List<AgentExecutor.Intermediat
58
58
}
59
59
60
60
for ( AgentExecutor .IntermediateStep step : intermediateSteps ) {
61
- var agentScratchpad = agentScratchpadTemplate .apply ( Map .of ("observation" , step .observation ()) );
61
+ var agentScratchpad = agentScratchpadTemplate
62
+ .apply ( Map .of ("observation" , step .observation ()) );
62
63
messages .add (new UserMessage (agentScratchpad .text ()));
63
- ;
64
64
}
65
65
66
66
return chatLanguageModel .generate ( messages , tools );
0 commit comments