Commit 0dc1611
authored
improvement(providers): align attachment dispatch to vendor SDK types (#4619)
* improvement(providers): align attachment dispatch to vendor SDK types
Post-merge audit of #4610 surfaced three follow-ups:
1. xAI Grok vision was blocked. Grok runs through the OpenAI-compatible
chat-completions endpoint, so removing xAI from UNSUPPORTED_FILE_PROVIDERS
and routing it through the image-only branch restores image attachments
on vision models.
2. Azure OpenAI chat-completions deployments blocked any file attachment.
Added a per-message image_url parts path; documents still require the
Responses API endpoint and throw a clear, actionable error.
3. Wire shapes were loosely typed (Record<string, unknown> arrays).
Replaced with `satisfies` clauses against each vendor SDK union at every
push site: OpenAI Responses/Chat, Anthropic ContentBlockParam, Gemini
Part, Bedrock ContentBlock members. AnthropicImageMediaType now derives
from Base64ImageSource['media_type'] so it tracks SDK updates.
Also collapsed the validation cascade into an exhaustive switch with
`never` enforcement, and dropped the redundant per-provider
formatMessagesForProvider call from xai/index.ts (providers/index.ts
already runs the dispatcher centrally).
* fix(providers): restore getProviderAttachmentMaxBytes export and xAI message dispatch
- Restore `getProviderAttachmentMaxBytes` — still consumed by agent-handler.ts
for per-provider attachment size limits in file hydration
- Restore `formatMessagesForProvider(allMessages, 'xai')` — providers/index.ts
does NOT dispatch centrally on this branch; each OpenAI-compat provider
formats its own messages. Without it, xAI Grok vision drops image attachments
* fix(providers): tighten ResponsesInputItem content type to SDK ResponseInputContent
Build fix: buildOpenAIMessageContent returns ResponseInputContent[] which
isn't assignable to Record<string, unknown>[] (ResponseInputText lacks an
index signature). Align the type to the SDK shape.1 parent cb9c2d5 commit 0dc1611
5 files changed
Lines changed: 153 additions & 87 deletions
File tree
- apps/sim/providers
- azure-openai
- openai
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
0 commit comments