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

Function asTextPrompt

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

* 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)

Source from the content-addressed store, hash-verified

41 * video / audio part is present (text-to-image models can't accept inputs).
42 */
43function 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 —

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected