mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-16 01:40:15 +08:00
fix(provider): handle audio parts in OpenAI Responses adapter
This commit is contained in:
@@ -71,8 +71,8 @@ class ProviderOpenAIResponses(ProviderOpenAIOfficial):
|
||||
if detail:
|
||||
image_part["detail"] = detail
|
||||
converted.append(image_part)
|
||||
elif part_type == "input_audio":
|
||||
converted.append(part)
|
||||
elif part_type in {"audio_url", "input_audio"}:
|
||||
converted.append({"type": text_type, "text": "[Audio]"})
|
||||
elif part_type == "think":
|
||||
continue
|
||||
else:
|
||||
|
||||
@@ -103,6 +103,38 @@ def test_chat_payload_to_responses_payload_converts_messages_and_tool_calls():
|
||||
]
|
||||
|
||||
|
||||
def test_chat_payload_to_responses_payload_replaces_audio_parts_with_placeholder():
|
||||
payload = {
|
||||
"model": "gpt-4.1",
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "text", "text": "listen"},
|
||||
{
|
||||
"type": "input_audio",
|
||||
"input_audio": {"data": "abc", "format": "wav"},
|
||||
},
|
||||
{"type": "audio_url", "audio_url": {"url": "data:audio/wav,abc"}},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
converted = ProviderOpenAIResponses._chat_payload_to_responses_payload(payload)
|
||||
|
||||
assert converted["input"] == [
|
||||
{
|
||||
"role": "user",
|
||||
"content": [
|
||||
{"type": "input_text", "text": "listen"},
|
||||
{"type": "input_text", "text": "[Audio]"},
|
||||
{"type": "input_text", "text": "[Audio]"},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def test_build_responses_request_shares_tool_and_extra_body_handling():
|
||||
provider = _make_provider()
|
||||
payload = {
|
||||
|
||||
Reference in New Issue
Block a user