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.

Example

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({ 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

Constructors

Properties

ToolType: StructuredToolInterface
llmChain: LLMChain<string, any>
stop?: string[]

Accessors

  • get allowedTools(): undefined | string[]
  • Returns undefined | string[]

Methods

  • 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.

    • Optional callbackManager: any

      Callback manager.

    Returns Promise<any>

    Action specifying what tool to use.

Generated using TypeDoc