MCPcopy Index your code
hub / github.com/simstudioai/sim / buildOpenRouterMessageContent

Function buildOpenRouterMessageContent

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

Source from the content-addressed store, hash-verified

584}
585
586export function buildOpenRouterMessageContent(
587 content: string | null | undefined,
588 files: UserFile[] | undefined,
589 providerId: ProviderId | string
590): string | OpenAIChatContentPart[] {
591 const attachments = prepareProviderAttachments(files, providerId)
592 if (attachments.length === 0) return content ?? ''
593
594 const parts: OpenAIChatContentPart[] = []
595 if (content) {
596 parts.push({
597 type: 'text',
598 text: content,
599 } satisfies OpenAI.Chat.Completions.ChatCompletionContentPartText)
600 }
601
602 for (const attachment of attachments) {
603 if (attachment.contentType === 'image') {
604 parts.push({
605 type: 'image_url',
606 image_url: { url: attachment.remoteUrl ?? attachment.dataUrl ?? '' },
607 } satisfies OpenAI.Chat.Completions.ChatCompletionContentPartImage)
608 } else {
609 parts.push({
610 type: 'file',
611 file: {
612 filename: attachment.filename,
613 file_data: attachment.remoteUrl ?? attachment.dataUrl ?? '',
614 },
615 } satisfies OpenAI.Chat.Completions.ChatCompletionContentPart.File)
616 }
617 }
618
619 return parts
620}
621
622function sanitizeBedrockName(filename: string): string {
623 const baseName = filename.replace(/\.[^/.]+$/, '').replace(/[^a-zA-Z0-9\s()[\]-]/g, ' ')

Callers 2

Calls 2

pushMethod · 0.45

Tested by

no test coverage detected