Skip to content

fix: skip empty streaming choices in prompt generation#3013

Open
nacim-coder wants to merge 2 commits into
ModelEngine-Group:mainfrom
nacim-coder:fix-3009-empty-streaming-choices
Open

fix: skip empty streaming choices in prompt generation#3013
nacim-coder wants to merge 2 commits into
ModelEngine-Group:mainfrom
nacim-coder:fix-3009-empty-streaming-choices

Conversation

@nacim-coder
Copy link
Copy Markdown

Fixes #3009.

Some OpenAI-compatible streaming providers can emit chunks with an empty choices array. In that case prompt generation crashed before reading the next content chunk.

This change skips chunks without choices before accessing choices[0].delta, matching the existing handling used elsewhere in the OpenAI streaming code.

Tested with:

PYTHONPATH=/repo:/repo/backend:/repo/sdk python -m pytest test/backend/utils/test_llm_utils.py -q

Result: 39 passed.

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.

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

1 participant