const prompt = PromptTemplate.fromTemplate("What is the answer to {question}?");

// Example of using LLMChain with OpenAI and a simple prompt
const chain = new LLMChain({
llm: new ChatOpenAI({ temperature: 0.9 }),
prompt,
});

// Running the chain with a single question
const result = await chain.call({
question: "What is the airspeed velocity of an unladen swallow?",
});
console.log("The answer is:", result);

Hierarchy (view full)

Implements

  • BaseCallbackManagerMethods

Constructors

Properties

handlers: BaseCallbackHandler[] = []
inheritableHandlers: BaseCallbackHandler[] = []
inheritableMetadata: Record<string, unknown> = {}
inheritableTags: string[] = []
metadata: Record<string, unknown> = {}
name: string = "callback_manager"
tags: string[] = []

Methods

  • Called at the start of a Chain run, with the chain name and inputs and the run ID.

    Parameters

    • chain: Serialized
    • inputs: ChainValues
    • runId: string = ...
    • runType: undefined | string = undefined
    • _tags: undefined | string[] = undefined
    • _metadata: undefined | Record<string, unknown> = undefined
    • runName: undefined | string = undefined

    Returns Promise<CallbackManagerForChainRun>

  • Called at the start of a Chat Model run, with the prompt(s) and the run ID.

    Parameters

    • llm: Serialized
    • messages: BaseMessage[][]
    • runId: undefined | string = undefined
    • _parentRunId: undefined | string = undefined
    • extraParams: undefined | Record<string, unknown> = undefined
    • _tags: undefined | string[] = undefined
    • _metadata: undefined | Record<string, unknown> = undefined
    • runName: undefined | string = undefined

    Returns Promise<CallbackManagerForLLMRun[]>

  • Called at the start of an LLM or Chat Model run, with the prompt(s) and the run ID.

    Parameters

    • llm: Serialized
    • prompts: string[]
    • runId: undefined | string = undefined
    • _parentRunId: undefined | string = undefined
    • extraParams: undefined | Record<string, unknown> = undefined
    • _tags: undefined | string[] = undefined
    • _metadata: undefined | Record<string, unknown> = undefined
    • runName: undefined | string = undefined

    Returns Promise<CallbackManagerForLLMRun[]>

  • Called at the start of a Tool run, with the tool name and input and the run ID.

    Parameters

    • tool: Serialized
    • input: string
    • runId: string = ...
    • _parentRunId: undefined | string = undefined
    • _tags: undefined | string[] = undefined
    • _metadata: undefined | Record<string, unknown> = undefined
    • runName: undefined | string = undefined

    Returns Promise<CallbackManagerForToolRun>