MCPcopy
hub / github.com/simstudioai/sim / buildOpenAICompatibleChatContent

Function buildOpenAICompatibleChatContent

apps/sim/providers/attachments.ts:558–584  ·  view source on GitHub ↗
(
  content: string | null | undefined,
  files: UserFile[] | undefined,
  providerId: ProviderId | string
)

Source from the content-addressed store, hash-verified

556}
557
558export 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
586export function buildOpenRouterMessageContent(
587 content: string | null | undefined,

Callers 2

Calls 2

pushMethod · 0.45

Tested by

no test coverage detected