Conversation
ChatMessage.content was typed Optional[Union[str, List[Dict[str, str]]]].
The OpenAI multimodal format nests a dict under image_url:
{"type": "image_url", "image_url": {"url": "..."}}
so Dict[str, str] fails validation and FastAPI returns 422 before the handler
runs — every vision request is rejected at the schema layer.
Widen the value type to Any (Dict[str, Any]) so multimodal content validates.
Any is already imported.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe type annotation for ChangesChatMessage Schema Type Widening
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
ChatMessage.contentis typedOptional[Union[str, List[Dict[str, str]]]](chat/openai/schema.py). The OpenAI multimodal format nests a dict underimage_url:{"type": "image_url", "image_url": {"url": "..."}}Dict[str, str]rejects that nested object, so FastAPI returns 422 before the handler runs — every vision request fails at the schema layer, even though VLM routing exists internally.Fix
Widen the value type to
Any(List[Dict[str, Any]]).Anyis already imported. One-line change.Present on
main(0.5.3).Summary by CodeRabbit