hermes: normalize routed vision messages
This commit is contained in:
parent
5dd13368c6
commit
bfd53100d9
@ -224,7 +224,7 @@ def _upstream_headers(token: str) -> dict[str, str]:
|
|||||||
def _normalize_input_images(response_input: list[Any]) -> None:
|
def _normalize_input_images(response_input: list[Any]) -> None:
|
||||||
"""Normalize Chat-Completions image parts for the Codex Responses API."""
|
"""Normalize Chat-Completions image parts for the Codex Responses API."""
|
||||||
for item in response_input:
|
for item in response_input:
|
||||||
if not isinstance(item, dict) or item.get("type") != "message":
|
if not isinstance(item, dict):
|
||||||
continue
|
continue
|
||||||
content = item.get("content")
|
content = item.get("content")
|
||||||
if not isinstance(content, list):
|
if not isinstance(content, list):
|
||||||
|
|||||||
@ -779,6 +779,28 @@ def test_codex_broker_auth_and_request_contract(tmp_path: Path, monkeypatch):
|
|||||||
"image_url": "data:image/png;base64,cHJpdmF0ZQ==",
|
"image_url": "data:image/png;base64,cHJpdmF0ZQ==",
|
||||||
"detail": "high",
|
"detail": "high",
|
||||||
}
|
}
|
||||||
|
switchyard_image_items = [
|
||||||
|
{
|
||||||
|
"role": "user",
|
||||||
|
"content": [
|
||||||
|
{"type": "input_text", "text": "What color is this?"},
|
||||||
|
{
|
||||||
|
"type": "image_url",
|
||||||
|
"image_url": {
|
||||||
|
"url": "data:image/png;base64,cHJpdmF0ZQ==",
|
||||||
|
"detail": "auto",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
assert module._validate_payload(
|
||||||
|
{"model": "gpt-5.6-terra", "input": switchyard_image_items}
|
||||||
|
)["input"][0]["content"][1] == {
|
||||||
|
"type": "input_image",
|
||||||
|
"image_url": "data:image/png;base64,cHJpdmF0ZQ==",
|
||||||
|
"detail": "auto",
|
||||||
|
}
|
||||||
with pytest.raises(ValueError, match="non-empty Responses image URL"):
|
with pytest.raises(ValueError, match="non-empty Responses image URL"):
|
||||||
module._validate_payload(
|
module._validate_payload(
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user