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.
18 lines (15 loc) • 425 B
text/typescript
import type {
LanguageModelV4Content,
LanguageModelV4Reasoning,
} from '@ai-sdk/provider';
export function extractReasoningContent(
content: LanguageModelV4Content[],
): string | undefined {
const parts = content.filter(
(content): content is LanguageModelV4Reasoning =>
content.type === 'reasoning',
);
return parts.length === 0
? undefined
: parts.map(content => content.text).join('\n');
}