langchain.js
    Preparing search index...

    Type Alias WrapModelCallHook<TSchema, TContext>

    WrapModelCallHook: (
        request: ModelRequest<NormalizedSchemaInput<TSchema>, TContext>,
        handler: WrapModelCallHandler<TSchema, TContext>,
    ) => PromiseOrValue<BaseMessage>

    Wrapper function type for the wrapModelCall hook. Allows middleware to intercept and modify model execution. This enables you to:

    • Modify the request before calling the model (e.g., change system prompt, add/remove tools)
    • Handle errors and retry with different parameters
    • Post-process the response
    • Implement custom caching, logging, or other cross-cutting concerns

    Type Parameters

    • TSchema extends BaseMessage | undefined = undefined
    • TContext = unknown

    Type Declaration