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.

20 lines (18 loc) 550 B
import { asArray, type Arrayable } from '@ai-sdk/provider-utils'; import type { Callback } from './callback'; /** * Notifies all provided callbacks with the given event in parallel. * Errors in callbacks do not break the generation flow. */ export async function notify<EVENT>(options: { event: EVENT; callbacks?: Arrayable<Callback<EVENT> | undefined | null>; }): Promise<void> { await Promise.all( asArray(options.callbacks).map(async callback => { try { await callback?.(options.event); } catch {} }), ); }