llmwire - v2.2.0
    Preparing search index...

    Interface Hooks

    Lifecycle hooks on the factory. provider is the provider id; model is the id the request asked for, if any.

    interface Hooks {
        onError?(
            ctx: {
                error: AIError;
                model?: string;
                provider: string;
                willRetry: boolean;
            },
        ): void
        | Promise<void>;
        onRequest?(
            ctx: { model?: string; provider: string; request: AIRequest },
        ): void | Promise<void>;
        onResponse?(
            ctx: {
                durationMs: number;
                model?: string;
                provider: string;
                response: AIResponse | AIStreamChunk;
            },
        ): void
        | Promise<void>;
    }
    Index
    • willRetry is true when the factory is about to retry the same provider; false before a fallback or the final failure.

      Parameters

      • ctx: { error: AIError; model?: string; provider: string; willRetry: boolean }

      Returns void | Promise<void>

    • Parameters

      • ctx: { model?: string; provider: string; request: AIRequest }

      Returns void | Promise<void>

    • response is the AIResponse, or the done chunk for a stream.

      Parameters

      • ctx: {
            durationMs: number;
            model?: string;
            provider: string;
            response: AIResponse | AIStreamChunk;
        }

      Returns void | Promise<void>