langchain.js
    Preparing search index...

    Agent that interoperates with Structured Tools using React logic.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    lc_namespace: string[] = ...
    llmChain: LLMChain
    outputParser: undefined | AgentActionOutputParser
    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 "structured-chat-zero-shot-react-description"

    • Returns string[]

    • Constructs the agent's scratchpad from a list of steps. If the agent's scratchpad is not empty, it prepends a message indicating that the agent has not seen any previous work.

      Parameters

      • steps: AgentStep[]

        Array of AgentStep instances to construct the scratchpad from.

      Returns Promise<string>

      A Promise that resolves to a string representing the agent's scratchpad.

    • Name of tool to use to terminate the chain.

      Returns string

    • Prefix to append the LLM call with.

      Returns string

    • Prefix to append the observation with.

      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 to use for this call.

      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
      • OptionalcallbackManager: any

      Returns Promise<AgentFinish>

    • Create prompt in the style of the agent.

      Parameters

      • tools: StructuredToolInterface[]

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

      • Optionalargs: StructuredChatCreatePromptArgs

        Arguments to create the prompt with.

        Interface for arguments used to create a prompt for a StructuredChatAgent.

        • OptionalhumanMessageTemplate?: string

          String to use directly as the human message template.

        • OptionalinputVariables?: string[]

          List of input variables the final prompt will expect.

        • OptionalmemoryPrompts?: BaseMessagePromptTemplate[]

          List of historical prompts from memory.

        • Optionalprefix?: string

          String to put before the list of tools.

        • Optionalsuffix?: string

          String to put after the list of tools.

      Returns any

    • Creates a string representation of the schemas of the provided tools.

      Parameters

      • tools: StructuredToolInterface[]

        Array of StructuredTool instances to create the schemas string from.

      Returns string

      A string representing the schemas of the provided tools.

    • Load an agent from a json-like object describing it.

      Parameters

      Returns Promise<Agent>

    • Creates a StructuredChatAgent from an LLM and a list of tools. Validates the tools, creates a prompt, and sets up an LLM chain for the agent.

      Parameters

      • llm: BaseLanguageModelInterface

        BaseLanguageModel instance to create the agent from.

      • tools: StructuredToolInterface[]

        Array of StructuredTool instances to create the agent from.

      • Optionalargs: StructuredChatCreatePromptArgs & AgentArgs

        Optional arguments to customize the creation of the agent. Can include arguments for creating the prompt and AgentArgs.

      Returns StructuredChatAgent

      A new instance of StructuredChatAgent.

    • Returns a default output parser for the StructuredChatAgent. If an LLM is provided, it creates an output parser with retry logic from the LLM.

      Parameters

      • Optionalfields: OutputParserArgs & { toolNames: string[] }

        Optional fields to customize the output parser. Can include an LLM and a list of tool names.

      Returns StructuredChatOutputParserWithRetries

      An instance of StructuredChatOutputParserWithRetries.

    • Returns string

    • Validates that all provided tools have a description. Throws an error if any tool lacks a description.

      Parameters

      • tools: StructuredToolInterface[]

        Array of StructuredTool instances to validate.

      Returns void