mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
fix(openai): handle missing 'text' key in responses API content blocks (#34198)
This commit is contained in:
@@ -4048,9 +4048,14 @@ def _construct_responses_api_input(messages: Sequence[BaseMessage]) -> list:
|
||||
if block_type in ("text", "output_text", "refusal"):
|
||||
msg_id = block.get("id")
|
||||
if block_type in ("text", "output_text"):
|
||||
# Defensive check: block may not have "text" key
|
||||
text = block.get("text")
|
||||
if text is None:
|
||||
# Skip blocks without text content
|
||||
continue
|
||||
new_block = {
|
||||
"type": "output_text",
|
||||
"text": block["text"],
|
||||
"text": text,
|
||||
"annotations": [
|
||||
_format_annotation_from_lc(annotation)
|
||||
for annotation in block.get("annotations") or []
|
||||
|
||||
Reference in New Issue
Block a user