@@ -124,7 +124,7 @@ def needs_to_do_action(self, user_input, agent_actions={}):
124
124
{ descriptions } """ },
125
125
{"role" : "user" ,
126
126
"content" : f"""{ user_input }
127
- Function call: """
127
+ Function call: """
128
128
}
129
129
]
130
130
functions = [
@@ -202,7 +202,7 @@ def process_functions(self, user_input, action="",):
202
202
{ descriptions } """ },
203
203
{"role" : "user" ,
204
204
"content" : f"""{ user_input }
205
- Function call: """
205
+ Function call: """
206
206
}
207
207
]
208
208
response = self .function_completion (messages , action = action )
@@ -314,9 +314,9 @@ def analyze(self, responses, prefix="Analyze the following text highlighting the
314
314
"role" : "user" ,
315
315
"content" : f"""{ prefix } :
316
316
317
- ```
318
- { string }
319
- ```
317
+ ```
318
+ { string }
319
+ ```
320
320
""" ,
321
321
}
322
322
]
@@ -478,7 +478,23 @@ def evaluate(self,user_input, conversation_history = [], critic=True, re_evaluat
478
478
action_picker_message += "\n \n Observation: " + observation
479
479
# if there is no action to do, we can just reply to the user with REPLY_ACTION
480
480
try :
481
- action = self .needs_to_do_action (action_picker_message ,agent_actions = picker_actions )
481
+ critic_msg = ""
482
+ if critic :
483
+ descriptions = self .action_description ("" , self .agent_actions )
484
+
485
+ messages = [
486
+ {"role" : "user" ,
487
+ "content" : f"""Transcript of AI assistant responding to user requests. Replies with the action to perform and the reasoning.
488
+ { descriptions } """ },
489
+ {"role" : "user" ,
490
+ "content" : f"""
491
+ This is the user input: { user_input }
492
+ Decide now the function to call and give a detailed explaination"""
493
+ }
494
+ ]
495
+ critic_msg = self .analyze (messages , prefix = "" , suffix = f"" )
496
+ logger .info ("==> Critic: {critic}" , critic = critic_msg )
497
+ action = self .needs_to_do_action (action_picker_message + "\n " + critic_msg ,agent_actions = picker_actions )
482
498
except Exception as e :
483
499
logger .error ("==> error: " )
484
500
logger .error (e )
0 commit comments