Skip to content

[Bug] SiliconFlow LLM agent generation fails with empty streaming choices #3009

@manfu931-lab

Description

@manfu931-lab

Nexent Version

v2.1.1

Problem Description

使用硅基流动大语言模型 deepseek-ai/DeepSeek-V4-Flash 时,模型连通性检测正常,状态显示可用。但在“智能体开发”页面点击“生成智能体”会报:

Model is unavailable. Please check the model status and try again.

后端日志显示真实错误为:

Failed to generate prompt from LLM: list index out of range

原因疑似是硅基流动流式响应中会出现 choices=[] 的 chunk,而 backend/utils/llm_utils.py 直接访问了 chunk.choices[0].delta

Reproduction Steps

  1. Docker 部署 Nexent v2.1.1。
  2. 在模型管理中添加硅基流动 LLM:
    • model: deepseek-ai/DeepSeek-V4-Flash
    • base_url: https://api.siliconflow.cn/v1/
  3. 点击模型连通性检测,结果显示可用。
  4. 进入智能体开发页面,选择该模型。
  5. 输入智能体描述并点击“生成智能体”。
  6. 前端提示模型不可用,后端日志出现 list index out of range

Additional Information

单独测试该模型时,非流式请求正常;流式请求也能返回内容,但会包含空 choices chunk:

ChatCompletionChunk(..., choices=[], ...)

建议在处理流式响应时增加判断:

if not getattr(chunk, "choices", None):
    continue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions