|
52 | 52 | import io.github.jeddict.ai.util.PropertyChangeEmitter; |
53 | 53 | import java.lang.reflect.InvocationTargetException; |
54 | 54 | import java.util.ArrayList; |
| 55 | +import java.util.Arrays; |
55 | 56 | import java.util.Collections; |
56 | 57 | import java.util.HashMap; |
57 | 58 | import java.util.List; |
@@ -228,7 +229,7 @@ public <T> T pairProgrammer(PairProgrammer.Specialist specialist) { |
228 | 229 |
|
229 | 230 | builder.hallucinatedToolNameStrategy((exec) -> { |
230 | 231 | final ToolExecutionRequest ter = (ToolExecutionRequest)exec; |
231 | | - |
| 232 | + |
232 | 233 | LOG.finest(() -> "tool hallucination: " + ter.name()); |
233 | 234 | return ToolExecutionResultMessage.from( |
234 | 235 | ter, "Error: there is no tool called " + ter.name() + " try with a different name" |
@@ -290,20 +291,32 @@ protected boolean probeToolSupport() { |
290 | 291 | // Otherwise probe the model by trying to trigger the execution of the |
291 | 292 | // ToolsProbingTool tool |
292 | 293 | // |
293 | | - final ToolsProbingTool probeTool = new ToolsProbingTool(); |
294 | | - final ToolsProber prober = AgenticServices.agentBuilder(ToolsProber.class) |
295 | | - .chatModel(model(false)) |
296 | | - .tools(probeTool) |
297 | | - .build(); |
298 | | - final boolean toolsSupport = prober.probe(probeTool.probeText); |
| 294 | + try { |
| 295 | + final ToolsProbingTool probeTool = new ToolsProbingTool(); |
| 296 | + final ToolsProber prober = AgenticServices.agentBuilder(ToolsProber.class) |
| 297 | + .chatModel(model(false)) |
| 298 | + .tools(probeTool) |
| 299 | + .build(); |
299 | 300 |
|
300 | | - probedModels.put(modelName, toolsSupport); |
| 301 | + final boolean toolsSupport = prober.probe(probeTool.probeText); |
301 | 302 |
|
302 | | - LOG.info( |
303 | | - LOG_MSG.formatted(modelName, (toolsSupport) ? "supports" : "does not support") |
304 | | - ); |
| 303 | + probedModels.put(modelName, toolsSupport); |
| 304 | + |
| 305 | + LOG.info( |
| 306 | + LOG_MSG.formatted(modelName, (toolsSupport) ? "supports" : "does not support") |
| 307 | + ); |
| 308 | + |
| 309 | + return toolsSupport; |
| 310 | + } catch (final Throwable t) { |
| 311 | + LOG.severe(() -> |
| 312 | + "error probing tool support, returning false %s\n%s".formatted( |
| 313 | + t.toString(), |
| 314 | + Arrays.toString(t.getStackTrace()) |
| 315 | + ) |
| 316 | + ); |
| 317 | + } |
305 | 318 |
|
306 | | - return toolsSupport; |
| 319 | + return false; |
307 | 320 | } |
308 | 321 |
|
309 | 322 |
|
|
0 commit comments