Agent that interoperates with Structured Tools using React logic.

Use the method instead.

Hierarchy (view full)

Constructors

Properties

ToolType: StructuredToolInterface<ZodObjectAny | ZodEffects<ZodObjectAny, any, {}> | JsonSchema7Type, unknown>
llmChain: LLMChain<string, LLMType>
outputParser: undefined | AgentActionOutputParser

Accessors

Methods

  • 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.

  • Create prompt in the style of the agent.

    Parameters

    • tools: StructuredToolInterface<ZodObjectAny | ZodEffects<ZodObjectAny, any, {}> | JsonSchema7Type, unknown>[]

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

    • Optionalargs: StructuredChatCreatePromptArgs

      Arguments to create the prompt with.

    Returns ChatPromptTemplate<any, any>

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

    Parameters

    • tools: StructuredToolInterface<ZodObjectAny | ZodEffects<ZodObjectAny, any, {}> | JsonSchema7Type, unknown>[]

      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

    • data: SerializedZeroShotAgent & {
          llm?: BaseLanguageModelInterface<any, BaseLanguageModelCallOptions>;
          tools?: ToolInterface<(ZodObjectAny | ZodEffects<ZodObjectAny, any, { [x: string]: any; }> | JsonSchema7Type), unknown>[];
      }

    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<any, BaseLanguageModelCallOptions>

      BaseLanguageModel instance to create the agent from.

    • tools: StructuredToolInterface<ZodObjectAny | ZodEffects<ZodObjectAny, any, {}> | JsonSchema7Type, unknown>[]

      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.

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

    Parameters

    • tools: StructuredToolInterface<ZodObjectAny | ZodEffects<ZodObjectAny, any, {}> | JsonSchema7Type, unknown>[]

      Array of StructuredTool instances to validate.

    Returns void