langchain.js
    Preparing search index...

    Class representing a single action agent using a LLMChain in LangChain. Extends the BaseSingleActionAgent class and provides methods for planning agent actions based on LLMChain outputs.

    const customPromptTemplate = new CustomPromptTemplate({
    tools: [new Calculator()],
    inputVariables: ["input", "agent_scratchpad"],
    });
    const customOutputParser = new CustomOutputParser();
    const agent = new LLMSingleActionAgent({
    llmChain: new LLMChain({
    prompt: customPromptTemplate,
    llm: new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 }),
    }),
    outputParser: customOutputParser,
    stop: ["\nObservation"],
    });
    const executor = new AgentExecutor({
    agent,
    tools: [new Calculator()],
    });
    const result = await executor.invoke({
    input:
    "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?",
    });

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    lc_namespace: string[] = ...
    llmChain: LLMChain
    stop?: string[]
    ToolType: StructuredToolInterface

    Accessors

    • get allowedTools(): undefined | string[]

      Returns undefined | string[]

    • get inputKeys(): string[]

      Returns string[]

    • get returnValues(): string[]

      Returns string[]

    Methods

    • Return the string type key uniquely identifying multi or single action agents.

      Returns string

    • Return the string type key uniquely identifying this class of agent.

      Returns string

    • Decide what to do given some input.

      Parameters

      • steps: AgentStep[]

        Steps the LLM has taken so far, along with observations from each.

      • inputs: ChainValues

        User inputs.

      • OptionalcallbackManager: any

        Callback manager.

      Returns Promise<any>

      Action specifying what tool to use.

    • Prepare the agent for output, if needed

      Parameters

      • _returnValues: AgentFinish
      • _steps: AgentStep[]

      Returns Promise<AgentFinish>

    • Return response when agent has been stopped due to max iterations

      Parameters

      • earlyStoppingMethod: StoppingMethod
      • _steps: AgentStep[]
      • _inputs: ChainValues
      • Optional_callbackManager: any

      Returns Promise<AgentFinish>