* Narrows a wire `MediaPrompt` to a text-only prompt, throwing if any image / * video / audio part is present (text-to-image models can't accept inputs).
(prompt: MediaPrompt)
| 41 | * video / audio part is present (text-to-image models can't accept inputs). |
| 42 | */ |
| 43 | function asTextPrompt(prompt: MediaPrompt): TextPrompt { |
| 44 | if (typeof prompt === 'string') return prompt |
| 45 | return prompt.map((part) => { |
| 46 | if (part.type === 'text') return part |
| 47 | throw new Error( |
| 48 | `Model does not support image inputs (received ${part.type} part)`, |
| 49 | ) |
| 50 | }) |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Like `asImagePrompt`, but additionally requires at least one image part — |