From ad0ab405f2438cc6646566f7f43e2dfd1c0e7cb0 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Wed, 24 Jun 2026 12:50:53 -0400 Subject: [PATCH] fix(schemas): ChatMessage.content accepts str | list for multimodal OpenAI ChatMessage content can be either a string (simple text) or a list of content parts (multimodal: text + image_url, etc.). Updated the type annotation to match the actual API. No behavioral change; this is a type-hint-only widening so callers can pass multimodal content via ChatMessage instead of dicts. Required by tests/test_openai_compatible.py::test_vision_multimodal_message which was passing raw dicts to OpenAICompatibleRequest (wrong - the field is typed list[ChatMessage]). With this widening, that test can now use ChatMessage(role='user', content=[...multimodal parts]) without losing type fidelity. --- src/openai_schemas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openai_schemas.py b/src/openai_schemas.py index 9f4a0928..0058a4be 100644 --- a/src/openai_schemas.py +++ b/src/openai_schemas.py @@ -48,7 +48,7 @@ class ToolCall: @dataclass(frozen=True) class ChatMessage: role: str - content: str + content: str | list # str for text; list of content parts for multimodal (text + image_url, etc.) tool_calls: Optional[tuple[ToolCall, ...]] = None tool_call_id: Optional[str] = None name: Optional[str] = None