Skip to content

Fix index out of range error when processing model output#69

Open
ldhldh wants to merge 1 commit intothemanojdesai:mainfrom
ldhldh:bugfix_llm_like_qwen_error_index_out_of_range
Open

Fix index out of range error when processing model output#69
ldhldh wants to merge 1 commit intothemanojdesai:mainfrom
ldhldh:bugfix_llm_like_qwen_error_index_out_of_range

Conversation

@ldhldh
Copy link

@ldhldh ldhldh commented Jun 26, 2025

Description of Changes

When using LLM like Qwen, an index out of range error occurs during the final output chunk because chunk.choices[0] may not exist. This PR adds a check for chunk.choices before accessing chunk.choices[0] to prevent this error.

Testing

  • Tested with the Qwen model (agent_server.model = 'qwen-plus') using the following code snippet:
    async for chunk in agent_server.stream_response(message=message):
        print(chunk, end='', flush=True)

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.

1 participant