Class BaseChatModel<CallOptions>Abstract

Base class for chat models. It extends the BaseLanguageModel class and provides methods for generating chat based on input messages.

Type Parameters

Hierarchy

Constructors

Properties

CallOptions: CallOptions
ParsedCallOptions: Omit<CallOptions, never>
caller: AsyncCaller

The async caller should be used by subclasses to make any async calls, which will thus benefit from the concurrency and retry logic.

verbose: boolean

Whether to print out response text.

callbacks?: Callbacks
metadata?: Record<string, unknown>
tags?: string[]
lc_runnable: boolean = true

Accessors

Methods

  • Makes a single call to the chat model.

    Parameters

    • messages: BaseMessageLike[]

      An array of BaseMessage instances.

    • Optional options: string[] | CallOptions

      The call options or an array of stop sequences.

    • Optional callbacks: Callbacks

      The callbacks for the language model.

    Returns Promise<BaseMessage>

    A Promise that resolves to a BaseMessage.

  • Makes a single call to the chat model with a prompt value.

    Parameters

    • promptValue: BasePromptValue

      The value of the prompt.

    • Optional options: string[] | CallOptions

      The call options or an array of stop sequences.

    • Optional callbacks: Callbacks

      The callbacks for the language model.

    Returns Promise<BaseMessage>

    A Promise that resolves to a BaseMessage.

  • Generates chat based on the input messages.

    Parameters

    • messages: BaseMessageLike[][]

      An array of arrays of BaseMessage instances.

    • Optional options: string[] | CallOptions

      The call options or an array of stop sequences.

    • Optional callbacks: Callbacks

      The callbacks for the language model.

    Returns Promise<LLMResult>

    A Promise that resolves to an LLMResult.

  • Get the parameters used to invoke the model

    Parameters

    • Optional _options: Omit<CallOptions, never>

    Returns any

  • Predicts the next message based on a text input.

    Parameters

    • text: string

      The text input.

    • Optional options: string[] | CallOptions

      The call options or an array of stop sequences.

    • Optional callbacks: Callbacks

      The callbacks for the language model.

    Returns Promise<string>

    A Promise that resolves to a string.

  • Stream all output from a runnable, as reported to the callback system. This includes all inner runs of LLMs, Retrievers, Tools, etc. Output is streamed as Log objects, which include a list of jsonpatch ops that describe how the state of the run has changed in each step, and the final state of the run. The jsonpatch ops can be applied in order to construct state.

    Parameters

    • input: BaseLanguageModelInput
    • Optional options: Partial<CallOptions>
    • Optional streamOptions: Omit<LogStreamCallbackHandlerInput, "autoClose">

    Returns AsyncGenerator<RunLogPatch, any, unknown>

  • Parameters

    • Rest ...llmOutputs: (undefined | Record<string, any>)[]

    Returns undefined | Record<string, any>

  • Helper method to transform an Iterator of Input values into an Iterator of Output values, with callbacks. Use this to implement stream() or transform() in Runnable subclasses.

    Type Parameters

    Parameters

    • inputGenerator: AsyncGenerator<I, any, unknown>
    • transformer: ((generator, runManager?, options?) => AsyncGenerator<O, any, unknown>)
        • (generator, runManager?, options?): AsyncGenerator<O, any, unknown>
        • Parameters

          • generator: AsyncGenerator<I, any, unknown>
          • Optional runManager: CallbackManagerForChainRun
          • Optional options: Partial<CallOptions>

          Returns AsyncGenerator<O, any, unknown>

    • Optional options: CallOptions & {
          runType?: string;
      }

    Returns AsyncGenerator<O, any, unknown>

Generated using TypeDoc