Class ChatAgent

Agent for the MRKL chain.

Hierarchy

Constructors

Properties

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

Accessors

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

  • get inputKeys(): string[]
  • Returns string[]

  • get returnValues(): string[]
  • Returns string[]

Methods

  • Constructs the agent's scratchpad, which is a string representation of the agent's previous steps.

    Parameters

    • steps: AgentStep[]

      Array of AgentStep instances representing the agent's previous steps.

    Returns Promise<string>

    Promise resolving 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.

    • Optional callbackManager: CallbackManager

      Callback manager to use for this call.

    Returns Promise<AgentAction | AgentFinish>

    Action specifying what tool to use.

  • Prepare the agent for output, if needed

    Parameters

    • _returnValues: Record<string, any>
    • _steps: AgentStep[]

    Returns Promise<Record<string, any>>

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

    Parameters

    • earlyStoppingMethod: StoppingMethod
    • steps: AgentStep[]
    • inputs: ChainValues
    • Optional callbackManager: CallbackManager

    Returns Promise<AgentFinish>

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

    Parameters

    • tools: Tool[]

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

    • Optional args: ChatCreatePromptArgs

      Arguments to create the prompt with.

    Returns ChatPromptTemplate<any, any>

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

    Parameters

    • data: Object

    Returns Promise<Agent>

  • Creates a ChatAgent instance using a language model, tools, and optional arguments.

    Parameters

    • llm: BaseLanguageModel<any, BaseLanguageModelCallOptions>

      BaseLanguageModel instance to use in the agent.

    • tools: Tool[]

      Array of Tool instances to include in the agent.

    • Optional args: ChatCreatePromptArgs & AgentArgs

      Optional arguments to customize the agent and prompt.

    Returns ChatAgent

    ChatAgent instance

  • Validates that all tools have descriptions. Throws an error if a tool without a description is found.

    Parameters

    • tools: Tool[]

      Array of Tool instances to validate.

    Returns void

    void

Generated using TypeDoc