( content: string | null | undefined, files: UserFile[] | undefined, providerId: ProviderId | string )
| 556 | } |
| 557 | |
| 558 | export function buildOpenAICompatibleChatContent( |
| 559 | content: string | null | undefined, |
| 560 | files: UserFile[] | undefined, |
| 561 | providerId: ProviderId | string |
| 562 | ): string | OpenAIChatContentPart[] { |
| 563 | const attachments = prepareProviderAttachments(files, providerId) |
| 564 | if (attachments.length === 0) return content ?? '' |
| 565 | |
| 566 | const parts: OpenAIChatContentPart[] = [] |
| 567 | if (content) { |
| 568 | parts.push({ |
| 569 | type: 'text', |
| 570 | text: content, |
| 571 | } satisfies OpenAI.Chat.Completions.ChatCompletionContentPartText) |
| 572 | } |
| 573 | |
| 574 | for (const attachment of attachments) { |
| 575 | parts.push({ |
| 576 | type: 'image_url', |
| 577 | image_url: { |
| 578 | url: attachment.remoteUrl ?? attachment.dataUrl ?? '', |
| 579 | }, |
| 580 | } satisfies OpenAI.Chat.Completions.ChatCompletionContentPartImage) |
| 581 | } |
| 582 | |
| 583 | return parts |
| 584 | } |
| 585 | |
| 586 | export function buildOpenRouterMessageContent( |
| 587 | content: string | null | undefined, |
no test coverage detected