• Create an agent that uses ReAct prompting.

    Parameters

    Returns Promise<any>

    A runnable sequence representing an agent. It takes as input all the same input variables as the prompt passed in does. It returns as output either an AgentAction or AgentFinish.

    Example

    import { AgentExecutor, createReactAgent } from "langchain/agents";
    import { pull } from "langchain/hub";
    import type { PromptTemplate } from "@langchain/core/prompts";

    import { OpenAI } from "@langchain/openai";

    // Define the tools the agent will have access to.
    const tools = [...];

    // Get the prompt to use - you can modify this!
    // If you want to see the prompt in full, you can at:
    // https://smith.langchain.com/hub/hwchase17/react
    const prompt = await pull<PromptTemplate>("hwchase17/react");

    const llm = new OpenAI({
    temperature: 0,
    });

    const agent = await createReactAgent({
    llm,
    tools,
    prompt,
    });

    const agentExecutor = new AgentExecutor({
    agent,
    tools,
    });

    const result = await agentExecutor.invoke({
    input: "what is LangChain?",
    });

Generated using TypeDoc