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.

13 lines (12 loc) 339 B
/** * Adds token counts while preserving an unknown total when both counts are * unknown. */ export function sumTokenCounts( tokenCount1: number | undefined, tokenCount2: number | undefined, ): number | undefined { return tokenCount1 == null && tokenCount2 == null ? undefined : (tokenCount1 ?? 0) + (tokenCount2 ?? 0); }