diff --git a/src/khoj/processor/conversation/openai/utils.py b/src/khoj/processor/conversation/openai/utils.py index d29796b3..2b5889c2 100644 --- a/src/khoj/processor/conversation/openai/utils.py +++ b/src/khoj/processor/conversation/openai/utils.py @@ -170,6 +170,7 @@ def completion_with_backoff( chunk.type == "chunk" and chunk.chunk.choices 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 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 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 if mode == "detect_start":