diff --git a/langchain-core/src/main/java/com/hw/langchain/tools/base/BaseTool.java b/langchain-core/src/main/java/com/hw/langchain/tools/base/BaseTool.java index 0341a1444..d9befd46f 100644 --- a/langchain-core/src/main/java/com/hw/langchain/tools/base/BaseTool.java +++ b/langchain-core/src/main/java/com/hw/langchain/tools/base/BaseTool.java @@ -91,13 +91,15 @@ public Map args() { public abstract Object innerRun(String args, Map kwargs); public Pair> toArgsAndKwargs(Object toolInput) { - if (toolInput instanceof String) { - return Pair.of(new Object[]{toolInput}, Maps.newHashMap()); - } else { - @SuppressWarnings("unchecked") + /* + * 20230308:入参为Map时转换,否则不进行转换 + * 原逻辑入参为非String和非Map时会出现将toolInput强转为Map报错 + * */ + if(toolInput instanceof Map){ Map mapInput = (Map) toolInput; return Pair.of(new Object[]{}, mapInput); } + return Pair.of(new Object[]{toolInput}, Maps.newHashMap()); } /**