openai[patch]: include 'type' key internally when streaming reasoning blocks (#31661)

Covered by existing tests.

Will make it easier to process streamed reasoning blocks.
This commit is contained in:
ccurme 2025-06-18 15:01:54 -04:00 committed by GitHub
parent 19544ba3c9
commit e2a0ff07fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -72,7 +72,7 @@ def _convert_to_v03_ai_message(
new_content: list[Union[dict, str]] = []
for block in message.content:
if isinstance(block, dict):
if block.get("type") == "reasoning" or "summary" in block:
if block.get("type") == "reasoning":
# Store a reasoning item in additional_kwargs (overwriting as in
# v0.3)
_ = block.pop("index", None)

View File

@ -3756,6 +3756,7 @@ def _convert_responses_chunk_to_generation_chunk(
{"index": chunk.summary_index, "type": "summary_text", "text": ""}
],
"index": current_index,
"type": "reasoning",
}
)
elif chunk.type == "response.image_generation_call.partial_image":
@ -3773,6 +3774,7 @@ def _convert_responses_chunk_to_generation_chunk(
}
],
"index": current_index,
"type": "reasoning",
}
)
else: