UNPKG

ai

Version:

AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.

16 lines (12 loc) 401 B
import { LanguageModelV3Content, LanguageModelV3Text } from '@ai-sdk/provider'; export function extractTextContent( content: LanguageModelV3Content[], ): string | undefined { const parts = content.filter( (content): content is LanguageModelV3Text => content.type === 'text', ); if (parts.length === 0) { return undefined; } return parts.map(content => content.text).join(''); }