MCPcopy Create free account
hub / github.com/TanStack/ai / asImagePrompt

Function asImagePrompt

examples/ts-react-media/src/lib/server-functions.ts:31–37  ·  view source on GitHub ↗

* Narrows a wire `MediaPrompt` to a text + image prompt for image-conditioned * models, throwing on any other part kind (video/audio) so unsupported inputs * fail fast rather than being silently dropped.

(prompt: MediaPrompt)

Source from the content-addressed store, hash-verified

29 * fail fast rather than being silently dropped.
30 */
31function asImagePrompt(prompt: MediaPrompt): ImagePrompt {
32 if (typeof prompt === 'string') return prompt
33 return prompt.map((part) => {
34 if (part.type === 'text' || part.type === 'image') return part
35 throw new Error(`Unsupported prompt part for image model: ${part.type}`)
36 })
37}
38
39/**
40 * Narrows a wire `MediaPrompt` to a text-only prompt, throwing if any image /

Callers 2

asImageToVideoPromptFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected