|  |  |  | @ -803,8 +803,10 @@ class Agent: | 
			
		
	
		
			
				
					|  |  |  |  |                             self.memory_query(task_prompt) | 
			
		
	
		
			
				
					|  |  |  |  |                          | 
			
		
	
		
			
				
					|  |  |  |  |                         # Generate response using LLM | 
			
		
	
		
			
				
					|  |  |  |  |                         response = self.llm(task_prompt, *args, **kwargs) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         response_args = ( | 
			
		
	
		
			
				
					|  |  |  |  |                             (task_prompt, *args) if img is None else (task_prompt, img, *args) | 
			
		
	
		
			
				
					|  |  |  |  |                         ) | 
			
		
	
		
			
				
					|  |  |  |  |                         response = self.call_llm(*response_args, **kwargs) | 
			
		
	
		
			
				
					|  |  |  |  |                          | 
			
		
	
		
			
				
					|  |  |  |  |                         # Check if response is a dictionary and has 'choices' key | 
			
		
	
		
			
				
					|  |  |  |  |                         if isinstance(response, dict) and 'choices' in response: | 
			
		
	
	
		
			
				
					|  |  |  | @ -813,7 +815,9 @@ class Agent: | 
			
		
	
		
			
				
					|  |  |  |  |                             # If response is already a string, use it as is | 
			
		
	
		
			
				
					|  |  |  |  |                             pass | 
			
		
	
		
			
				
					|  |  |  |  |                         else: | 
			
		
	
		
			
				
					|  |  |  |  |                             raise ValueError(f"Unexpected response format: {type(response)}") | 
			
		
	
		
			
				
					|  |  |  |  |                             raise ValueError( | 
			
		
	
		
			
				
					|  |  |  |  |                                 f"Unexpected response format: {type(response)}" | 
			
		
	
		
			
				
					|  |  |  |  |                             ) | 
			
		
	
		
			
				
					|  |  |  |  |                          | 
			
		
	
		
			
				
					|  |  |  |  |                         # Check and execute tools | 
			
		
	
		
			
				
					|  |  |  |  |                         if self.tools is not None: | 
			
		
	
	
		
			
				
					|  |  |  | @ -822,14 +826,14 @@ class Agent: | 
			
		
	
		
			
				
					|  |  |  |  |                          | 
			
		
	
		
			
				
					|  |  |  |  |                         # Log the step metadata | 
			
		
	
		
			
				
					|  |  |  |  |                         logged = self.log_step_metadata( | 
			
		
	
		
			
				
					|  |  |  |  |                             loop_count, task_prompt, response | 
			
		
	
		
			
				
					|  |  |  |  |                             loop_count,  | 
			
		
	
		
			
				
					|  |  |  |  |                             task_prompt,  | 
			
		
	
		
			
				
					|  |  |  |  |                             response | 
			
		
	
		
			
				
					|  |  |  |  |                         ) | 
			
		
	
		
			
				
					|  |  |  |  |                         logger.info(logged) | 
			
		
	
		
			
				
					|  |  |  |  |                          | 
			
		
	
		
			
				
					|  |  |  |  |                         # Conver to a str if the response is not a str | 
			
		
	
		
			
				
					|  |  |  |  |                         response = self.llm_output_parser( | 
			
		
	
		
			
				
					|  |  |  |  |                             response | 
			
		
	
		
			
				
					|  |  |  |  |                         ) | 
			
		
	
		
			
				
					|  |  |  |  |                         # Convert to a str if the response is not a str | 
			
		
	
		
			
				
					|  |  |  |  |                         response = self.llm_output_parser(response) | 
			
		
	
		
			
				
					|  |  |  |  |                          | 
			
		
	
		
			
				
					|  |  |  |  |                         # Print | 
			
		
	
		
			
				
					|  |  |  |  |                         if self.streaming_on is True: | 
			
		
	
	
		
			
				
					|  |  |  | @ -839,17 +843,17 @@ class Agent: | 
			
		
	
		
			
				
					|  |  |  |  |                          | 
			
		
	
		
			
				
					|  |  |  |  |                         # Add the response to the memory | 
			
		
	
		
			
				
					|  |  |  |  |                         self.short_memory.add( | 
			
		
	
		
			
				
					|  |  |  |  |                             role=self.agent_name, content=response | 
			
		
	
		
			
				
					|  |  |  |  |                             role=self.agent_name, | 
			
		
	
		
			
				
					|  |  |  |  |                             content=response | 
			
		
	
		
			
				
					|  |  |  |  |                         ) | 
			
		
	
		
			
				
					|  |  |  |  |                          | 
			
		
	
		
			
				
					|  |  |  |  |                         # Add to all responses | 
			
		
	
		
			
				
					|  |  |  |  |                         all_responses.append(response) | 
			
		
	
		
			
				
					|  |  |  |  |                          | 
			
		
	
		
			
				
					|  |  |  |  |                         # TODO: Implement reliablity check | 
			
		
	
		
			
				
					|  |  |  |  |                         # TODO: Implement reliability check | 
			
		
	
		
			
				
					|  |  |  |  |                         if self.tools is not None: | 
			
		
	
		
			
				
					|  |  |  |  |                             # self.parse_function_call_and_execute(response) | 
			
		
	
		
			
				
					|  |  |  |  |                             self.parse_and_execute_tools(response) | 
			
		
	
		
			
				
					|  |  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |  |                         # if self.code_interpreter is True: | 
			
		
	
		
			
				
					|  |  |  |  |                         #     # Parse the code and execute | 
			
		
	
		
			
				
					|  |  |  |  |                         #     logger.info("Parsing code and executing...") | 
			
		
	
	
		
			
				
					|  |  |  | 
 |