mirror of
https://github.com/fawney19/Aether.git
synced 2026-01-03 00:02:28 +08:00
fix: detect OpenAI format stream completion via finish_reason
- Add detection of finish_reason in OpenAI API responses to mark stream completion - Ensures OpenAI API streams are properly marked as complete even without explicit completion events - Complements existing completion event detection for other API formats
This commit is contained in:
@@ -127,6 +127,13 @@ class StreamProcessor:
|
||||
if event_type in ("response.completed", "message_stop"):
|
||||
ctx.has_completion = True
|
||||
|
||||
# 检查 OpenAI 格式的 finish_reason
|
||||
choices = data.get("choices", [])
|
||||
if choices and isinstance(choices, list) and len(choices) > 0:
|
||||
finish_reason = choices[0].get("finish_reason")
|
||||
if finish_reason is not None:
|
||||
ctx.has_completion = True
|
||||
|
||||
async def prefetch_and_check_error(
|
||||
self,
|
||||
byte_iterator: Any,
|
||||
|
||||
Reference in New Issue
Block a user