[llm_core] stream_llm duplicates 3 nearly-identical streaming parser blocks #716
Labels
No labels
area:chat
area:core
area:llm
area:routes
area:tools
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
refactor
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
sleepy/odysseus#716
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
File:
src/llm_core.pyfunctionstream_llm(lines 740-1063)The
stream_llmfunction has three separate streaming parser blocks with near-identical error handling:All three blocks share the same error handling pattern:
This 20-line error block is copy-pasted 3 times. The only difference between the blocks is the stream parsing logic.
Fix: Extract the error handling into a context manager or decorator. Each provider parser should only implement its unique parsing logic. The connection opening, error handling, and dead-host tracking should be shared.