mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-23 15:19:33 +00:00
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:
parent
19544ba3c9
commit
e2a0ff07fd
@ -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)
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user