( provider: AttachmentProvider, mimeType: string, contentType: PreparedProviderAttachment['contentType'], extension: string )
| 272 | } |
| 273 | |
| 274 | function isMimeTypeSupportedByProvider( |
| 275 | provider: AttachmentProvider, |
| 276 | mimeType: string, |
| 277 | contentType: PreparedProviderAttachment['contentType'], |
| 278 | extension: string |
| 279 | ): boolean { |
| 280 | switch (provider) { |
| 281 | case 'openai': |
| 282 | return isImageMimeType(mimeType) || isOpenAIDocumentMimeType(mimeType) |
| 283 | case 'anthropic': |
| 284 | return ( |
| 285 | isImageMimeType(mimeType) || mimeType === PDF_MIME_TYPE || isTextDocumentMimeType(mimeType) |
| 286 | ) |
| 287 | case 'google': |
| 288 | return GEMINI_INLINE_MIME_TYPES.has(mimeType) || isTextDocumentMimeType(mimeType) |
| 289 | case 'bedrock': |
| 290 | return ( |
| 291 | (contentType === 'image' && BEDROCK_IMAGE_FORMATS.has(extension)) || |
| 292 | (contentType === 'document' && BEDROCK_DOCUMENT_FORMATS.has(extension)) || |
| 293 | (contentType === 'video' && BEDROCK_VIDEO_FORMATS.has(extension)) |
| 294 | ) |
| 295 | case 'openrouter': |
| 296 | return isImageMimeType(mimeType) || mimeType === PDF_MIME_TYPE |
| 297 | case 'mistral': |
| 298 | case 'groq': |
| 299 | case 'fireworks': |
| 300 | case 'together': |
| 301 | case 'baseten': |
| 302 | case 'ollama': |
| 303 | case 'vllm': |
| 304 | case 'litellm': |
| 305 | case 'xai': |
| 306 | return isImageMimeType(mimeType) |
| 307 | case 'deepseek': |
| 308 | case 'cerebras': |
| 309 | case 'sakana': |
| 310 | return false |
| 311 | default: { |
| 312 | const _exhaustive: never = provider |
| 313 | return _exhaustive |
| 314 | } |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | function validateProviderSupport( |
| 319 | attachment: Omit<PreparedProviderAttachment, 'providerMimeType' | 'dataUrl' | 'text'>, |
no test coverage detected