Spaces:
Sleeping
Sleeping
Update agent.py
Browse files
agent.py
CHANGED
@@ -104,6 +104,28 @@ If you have the final answer, respond with an empty plan and the answer in the '
|
|
104 |
yield ActionOutput(output=final_answer, is_final_answer=is_final)
|
105 |
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
# --- MÉTHODES ADDITIONNELLES POUR LA ROBUSTESSE ---
|
108 |
# Bien que non explicitement listées comme abstraites, elles sont
|
109 |
# appelées par la logique interne et doivent être présentes.
|
|
|
104 |
yield ActionOutput(output=final_answer, is_final_answer=is_final)
|
105 |
|
106 |
|
107 |
+
def execute_tool_call(self, tool_name: str, arguments: dict) -> any:
|
108 |
+
"""
|
109 |
+
Exécute un outil avec les arguments fournis. C'est la fonction qui manquait.
|
110 |
+
"""
|
111 |
+
if tool_name not in self.tools:
|
112 |
+
raise AgentToolExecutionError(f"Outil inconnu '{tool_name}'. Les outils disponibles sont : {', '.join(self.tools.keys())}", self.logger)
|
113 |
+
|
114 |
+
tool = self.tools[tool_name]
|
115 |
+
|
116 |
+
try:
|
117 |
+
# La plupart des outils attendent les arguments directement
|
118 |
+
return tool(**arguments)
|
119 |
+
except TypeError:
|
120 |
+
# Certains outils plus simples attendent un seul argument positionnel
|
121 |
+
try:
|
122 |
+
return tool(list(arguments.values())[0])
|
123 |
+
except Exception as e:
|
124 |
+
raise AgentToolExecutionError(f"Erreur lors de l'exécution de l'outil '{tool_name}' avec les arguments {arguments}: {e}", self.logger)
|
125 |
+
except Exception as e:
|
126 |
+
raise AgentToolExecutionError(f"Erreur inattendue lors de l'exécution de l'outil '{tool_name}': {e}", self.logger)
|
127 |
+
|
128 |
+
|
129 |
# --- MÉTHODES ADDITIONNELLES POUR LA ROBUSTESSE ---
|
130 |
# Bien que non explicitement listées comme abstraites, elles sont
|
131 |
# appelées par la logique interne et doivent être présentes.
|