Agent for the MRKL chain.


const agent = new ZeroShotAgent({
llmChain: new LLMChain({
llm: new ChatOpenAI({ temperature: 0 }),
prompt: ZeroShotAgent.createPrompt([new SerpAPI(), new Calculator()], {
prefix: `Answer the following questions as best you can, but speaking as a pirate might speak. You have access to the following tools:`,
suffix: `Begin! Remember to speak as a pirate when giving your final answer. Use lots of "Args"
Question: {input}
{agent_scratchpad}`,
inputVariables: ["input", "agent_scratchpad"],
}),
}),
allowedTools: ["search", "calculator"],
});

const result = await agent.invoke({
input: `Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?`,
});

Use the createReactAgent method instead.

Hierarchy (view full)

Constructors

Properties

ToolType: ToolInterface
llmChain: LLMChain<string, any>
outputParser: undefined | AgentActionOutputParser

Accessors

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.

    • OptionalcallbackManager: any

      Callback manager to use for this call.

    Returns Promise<any>

    Action specifying what tool to use.

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

    Parameters

    • earlyStoppingMethod: StoppingMethod
    • steps: AgentStep[]
    • inputs: ChainValues
    • OptionalcallbackManager: any

    Returns Promise<AgentFinish>