langchain4j
langchain4j copied to clipboard
[BUG] zhipu-ai response parse error
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $ at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226) at com.google.gson.Gson.fromJson(Gson.java:932) at com.google.gson.Gson.fromJson(Gson.java:897) at com.google.gson.Gson.fromJson(Gson.java:846) at com.google.gson.Gson.fromJson(Gson.java:817)
dev.langchain4j.model.zhipu.DefaultZhipuAiHelper#aiMessageFrom if (content.startsWith("```json") && content.contains("{") && content.contains("}")) { return AiMessage.from(content.substring(content.indexOf("{"), content.lastIndexOf("}") + 1)); }
@langchain4j @1402564807
@cslcsl490 Hello! Could you please send me the calling example?
@cslcsl490 Hello! Could you please send me the calling example?
AiMessage { text = "```json
{
"xxxx": "xxx"
} ```" toolExecutionRequests = null
like this
content.lastIndexOf("}") + 1)
Hello, can you send the complete stack information and calling example? I couldn’t reproduce it through this simple example.
I suspect this issue is not related specifically to ZhipuAI, it should be fixed for all LLM providers: https://github.com/langchain4j/langchain4j/issues/859