mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-02 21:19:12 +00:00
Extract thought stream from reasoning_content of openai model providers
Grok 3 mini at least sends thoughts in reasoning_content field of streamed chunk delta. Extract model thoughts from that when available.
This commit is contained in:
@@ -147,6 +147,12 @@ def completion_with_backoff(
|
||||
aggregated_response += chunk.delta
|
||||
elif chunk.type == "thought.delta":
|
||||
thoughts += chunk.delta
|
||||
elif (
|
||||
chunk.type == "chunk"
|
||||
and chunk.chunk.choices
|
||||
and hasattr(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:
|
||||
tool_ids += [tool_call.id for tool_call in chunk.chunk.choices[0].delta.tool_calls]
|
||||
elif chunk.type == "tool_calls.function.arguments.done":
|
||||
|
||||
Reference in New Issue
Block a user