Error handling.
This commit is contained in:
		
							parent
							
								
									bdd9ad0c5a
								
							
						
					
					
						commit
						e9f7e7ec89
					
				| @ -185,7 +185,12 @@ class EventHandler(AssistantEventHandler): | |||||||
|         for tool in data.required_action.submit_tool_outputs.tool_calls: |         for tool in data.required_action.submit_tool_outputs.tool_calls: | ||||||
|             for function in self.agent.tools: |             for function in self.agent.tools: | ||||||
|                 if function.__name__ == tool.function.name: |                 if function.__name__ == tool.function.name: | ||||||
|                     tool_outputs.append({"tool_call_id": tool.id, "output": str(function(**json.loads(tool.function.arguments)))}) |                     result = None | ||||||
|  |                     try: | ||||||
|  |                         result = function(**json.loads(tool.function.arguments)) | ||||||
|  |                     except Exception as ex: | ||||||
|  |                         result = str(ex) | ||||||
|  |                     tool_outputs.append({"tool_call_id": tool.id, "output": str(result)}) | ||||||
| 
 | 
 | ||||||
|         self.submit_tool_outputs(tool_outputs, run_id) |         self.submit_tool_outputs(tool_outputs, run_id) | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user