fix: return tool result directly for detected intents
This commit is contained in:
1 parent
9970bba6c7
commit
a2f933edee
1 file changed
+12
-2
+12
-2
@@ -402,8 +402,18 @@ For other questions, just answer normally without tools."""
|
||||
detected_tool = self._detect_intent(user_content)
|
||||
if detected_tool:
|
||||
result = self._execute_tool(detected_tool)
|
||||
tool_result_text = self._format_tool_result(detected_tool, result)
|
||||
self.messages.append(HumanMessage(content=tool_result_text))
|
||||
|
||||
# Format result as a clean response
|
||||
try:
|
||||
result_data = json.loads(result) if isinstance(result, str) else result
|
||||
if isinstance(result_data, dict):
|
||||
if "result" in result_data:
|
||||
return {"messages": self.messages, "response": result_data["result"]}
|
||||
elif "error" in result_data:
|
||||
return {"messages": self.messages, "response": f"Errore: {result_data['error']}"}
|
||||
except:
|
||||
pass
|
||||
return {"messages": self.messages, "response": str(result)}
|
||||
|
||||
# Loop principale: risposta -> parse tools -> esegui -> ripeti
|
||||
iteration = 0
|
||||
|
||||
Reference in new issue
Block a user