mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-02 09:22:36 +00:00
fix(providers): sanitize azure responses input messages
This commit is contained in:
parent
61d7411238
commit
ded0967c18
@ -87,7 +87,7 @@ class AzureOpenAIProvider(LLMProvider):
|
||||
) -> dict[str, Any]:
|
||||
"""Build the Responses API request body from Chat-Completions-style args."""
|
||||
deployment = model or self.default_model
|
||||
instructions, input_items = convert_messages(messages)
|
||||
instructions, input_items = convert_messages(self._sanitize_empty_content(messages))
|
||||
|
||||
body: dict[str, Any] = {
|
||||
"model": deployment,
|
||||
|
||||
@ -150,6 +150,19 @@ def test_build_body_image_conversion():
|
||||
assert image_block["image_url"] == "https://example.com/img.png"
|
||||
|
||||
|
||||
def test_build_body_sanitizes_single_dict_content_block():
|
||||
"""Single content dicts should be preserved via shared message sanitization."""
|
||||
provider = AzureOpenAIProvider(api_key="k", api_base="https://r.com", default_model="gpt-4o")
|
||||
messages = [{
|
||||
"role": "user",
|
||||
"content": {"type": "text", "text": "Hi from dict content"},
|
||||
}]
|
||||
|
||||
body = provider._build_body(messages, None, None, 4096, 0.7, None, None)
|
||||
|
||||
assert body["input"][0]["content"] == [{"type": "input_text", "text": "Hi from dict content"}]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# chat() — non-streaming
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user