mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-10 05:39:11 +00:00
Handle unset reasoning, response chunk from openai api while streaming
This commit is contained in:
@@ -170,6 +170,7 @@ def completion_with_backoff(
|
|||||||
chunk.type == "chunk"
|
chunk.type == "chunk"
|
||||||
and chunk.chunk.choices
|
and chunk.chunk.choices
|
||||||
and hasattr(chunk.chunk.choices[0].delta, "reasoning_content")
|
and hasattr(chunk.chunk.choices[0].delta, "reasoning_content")
|
||||||
|
and chunk.chunk.choices[0].delta.reasoning_content
|
||||||
):
|
):
|
||||||
thoughts += chunk.chunk.choices[0].delta.reasoning_content
|
thoughts += chunk.chunk.choices[0].delta.reasoning_content
|
||||||
elif chunk.type == "chunk" and chunk.chunk.choices and chunk.chunk.choices[0].delta.tool_calls:
|
elif chunk.type == "chunk" and chunk.chunk.choices and chunk.chunk.choices[0].delta.tool_calls:
|
||||||
@@ -1075,6 +1076,10 @@ async def ain_stream_thought_processor(
|
|||||||
yield chunk
|
yield chunk
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if chunk.choices[0].delta.content is None:
|
||||||
|
# If delta content is None, we can't process it, just yield the chunk
|
||||||
|
continue
|
||||||
|
|
||||||
buf += chunk.choices[0].delta.content
|
buf += chunk.choices[0].delta.content
|
||||||
|
|
||||||
if mode == "detect_start":
|
if mode == "detect_start":
|
||||||
|
|||||||
Reference in New Issue
Block a user