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