Skip to content

fix:增加流式模型构建异常处理,防止模型导致崩溃 - #38

Open
j2016-java wants to merge 1 commit into
LangChat:mainfrom
j2016-java:main
Open

j2016-java wants to merge 1 commit into
LangChat:mainfrom
j2016-java:main

Conversation

@j2016-java

Copy link
Copy Markdown

Closes #36

问题描述

当配置的阿里 Qwen 模型无效(如 API Key 错误、网络不通等)时,底层 LangChain4j 的 QwenHelper 会在处理流式响应时抛出 NoSuchElementException,导致对话中断并报错。

修复方案

ModelStoreFactory.chatHandler 中构建流式模型时,增加了 try-catch 异常捕获机制。
当捕获到异常时,仅记录错误日志并跳过该模型的加载,防止单个模型配置错误导致整个流式对话服务崩溃。

修改文件

  • langchat-ai/langchat-ai-biz/src/main/java/cn/tycoding/langchat/ai/core/provider/factory/ModelStoreFactory.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

配置了阿里模型,但是对话一直为null是什么问题

1 participant