Fix Responses API request handling (#25881)
Co-authored-by: Kai-Hsun Chen <kaihsun@apache.org> Co-authored-by: Kristin Cowalcijk <kristincowalcijk@gmail.com> Co-authored-by: aerosta <63026763+aerosta@users.noreply.github.com> Co-authored-by: glaziermag <glaziermag@users.noreply.github.com> Co-authored-by: Blake Ledden <blake.ledden@gmail.com> Co-authored-by: PanJason <pyyjason@gmail.com> Co-authored-by: Leoyzen <leoyzen@gmail.com> Co-authored-by: kennyu <966806+kennyu@users.noreply.github.com>
This commit is contained in:
co-authored by
Kai-Hsun Chen
Kristin Cowalcijk
aerosta
glaziermag
Blake Ledden
PanJason
Leoyzen
kennyu
parent
b3270264e4
commit
85712fa5b0
@@ -157,14 +157,16 @@ def process_content_for_template_format(
|
||||
if isinstance(chunk, dict):
|
||||
chunk_type = chunk.get("type")
|
||||
|
||||
if chunk_type == "image_url":
|
||||
if chunk_type in ("image_url", "input_image"):
|
||||
image_obj = chunk.get("image_url") or {}
|
||||
if isinstance(image_obj, str):
|
||||
image_obj = {"url": image_obj, "detail": chunk.get("detail")}
|
||||
mdp = image_obj.get("max_dynamic_patch", None)
|
||||
# Also allow flat style: chunk["max_dynamic_patch"]
|
||||
image_data.append(
|
||||
ImageData(
|
||||
url=image_obj["url"],
|
||||
detail=image_obj.get("detail", "auto"),
|
||||
detail=image_obj.get("detail") or "auto",
|
||||
max_dynamic_patch=mdp,
|
||||
)
|
||||
)
|
||||
@@ -194,13 +196,15 @@ def process_content_for_template_format(
|
||||
audio_data.append(chunk["audio_url"]["url"])
|
||||
# Normalize to simple 'audio' type
|
||||
processed_content_parts.append({"type": "audio"})
|
||||
elif chunk_type == "text":
|
||||
elif chunk_type in ("text", "input_text"):
|
||||
# For v32 encoding, collect text parts separately
|
||||
if use_dpsk_v32_encoding:
|
||||
text_parts.append(chunk["text"])
|
||||
else:
|
||||
# Keep text content as-is for openai format
|
||||
processed_content_parts.append(chunk)
|
||||
processed_content_parts.append(
|
||||
{"type": "text", "text": chunk["text"]}
|
||||
)
|
||||
elif chunk_type == "tool_reference":
|
||||
# GLM-specific extension: pass through so the chat template
|
||||
# can match tool_reference.name against tools[*].function.name
|
||||
@@ -220,7 +224,7 @@ def process_content_for_template_format(
|
||||
# String format: flatten to text only (for templates like DeepSeek)
|
||||
text_parts = []
|
||||
for chunk in msg_dict["content"]:
|
||||
if isinstance(chunk, dict) and chunk.get("type") == "text":
|
||||
if isinstance(chunk, dict) and chunk.get("type") in ("text", "input_text"):
|
||||
text_parts.append(chunk["text"])
|
||||
# Note: For string format, we ignore images/audio since the template
|
||||
# doesn't expect structured content - multimodal placeholders would
|
||||
|
||||
@@ -257,6 +257,9 @@ class Qwen3Detector(BaseReasoningFormatDetector):
|
||||
think_excluded_tokens=think_excluded_tokens,
|
||||
force_reasoning=force_reasoning,
|
||||
stream_reasoning=stream_reasoning,
|
||||
# Qwen3.5 sometimes opens ``<tool_call>`` without closing
|
||||
# ``</think>``; treat it as an implicit reasoning close.
|
||||
tool_start_token="<tool_call>",
|
||||
continue_final_message=continue_final_message,
|
||||
previous_content=previous_content,
|
||||
thinks_internally=True,
|
||||
|
||||
Reference in New Issue
Block a user