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 method instead.

Hierarchy (view full)

Constructors

Properties

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

Accessors

Methods

  • Create prompt in the style of the zero shot agent.

    Parameters

    • tools: ToolInterface<ZodObjectAny>[]

      List of tools the agent will have access to, used to format the prompt.

    • Optionalargs: ZeroShotCreatePromptArgs

      Arguments to create the prompt with.

    Returns PromptTemplate<any, any>

  • Validates the tools for the ZeroShotAgent. Throws an error if any tool does not have a description.

    Parameters

    • tools: ToolInterface<ZodObjectAny>[]

      List of tools to validate.

    Returns void