From 72d0914a7abcad9178d983a20d5f803ade4b1f65 Mon Sep 17 00:00:00 2001 From: jie65535 Date: Mon, 23 Dec 2024 20:41:07 +0800 Subject: [PATCH] Fix tool execution failure --- src/main/kotlin/JChatGPT.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/JChatGPT.kt b/src/main/kotlin/JChatGPT.kt index 3275fe8..1688ae9 100644 --- a/src/main/kotlin/JChatGPT.kt +++ b/src/main/kotlin/JChatGPT.kt @@ -339,7 +339,12 @@ object JChatGPT : KotlinPlugin( val args = function.argumentsAsJsonOrNull() logger.info("Calling ${function.name}(${args})") // 执行函数 - val result = agent.execute(args) + val result = try { + agent.execute(args) + } catch (e: Throwable) { + logger.error("Failed to call ${function.name}", e) + "工具调用失败,请尝试自行回答用户,或如实告知。" + } logger.info("Result=$result") // 过会撤回加载消息 if (receipt != null) {