Node Details

  • Name: toolAgent

  • Type: AgentExecutor

  • Category: [[Agents]]

  • Version: 2.0

  • Icon: toolAgent.png

Description

This agent leverages the function calling capabilities of advanced chat models to select and use tools dynamically. It’s capable of maintaining context over multiple interactions, using tools to gather information or perform actions, and providing coherent responses based on the tools’ outputs.

Parameters

  1. Tools (Required)

    • Type: Tool[]

    • Description: A list of tools that the agent can use to perform tasks or gather information.

  2. Memory (Required)

    • Type: BaseChatMemory

    • Description: The memory component used to store and retrieve conversation history.

  3. Tool Calling Chat Model (Required)

    • Type: BaseChatModel

    • Description: The chat model used for generating responses and making decisions. Must be capable of function calling (e.g., ChatOpenAI, ChatMistral, ChatAnthropic, ChatGoogleGenerativeAI, ChatVertexAI, GroqChat).

  4. Chat Prompt Template (Optional)

    • Type: ChatPromptTemplate

    • Description: Override existing prompt with Chat Prompt Template. Human Message must include

      variable.

  5. System Message (Optional)

    • Type: string

    • Default: “You are a helpful AI assistant.”

    • Description: If Chat Prompt Template is provided, this will be ignored.

    • Additional Params: true

  6. Input Moderation (Optional)

    • Type: Moderation[]

    • Description: Moderation tools to detect and prevent harmful input.

  7. Max Iterations (Optional)

    • Type: number

    • Description: The maximum number of iterations the agent will perform for a single input.

    • Additional Params: true

Input

  • A string containing the user’s message or query.

Output

  • An object containing:

    • text: The agent’s response to the user’s input

    • sourceDocuments: (optional) Any source documents used in formulating the response

    • usedTools: (optional) A list of tools used by the agent during processing

How It Works

  1. The agent is initialized with the provided tools, chat model, memory, and optional parameters.

  2. It receives a user input, which is first checked by any specified moderation tools.

  3. The agent then:

    • Retrieves relevant context from its memory

    • Analyzes the input and context to determine the next action

    • Uses function calling to select and execute appropriate tools

    • Generates a response using the chat model

  4. The response, along with any used tools or source documents, is returned.

  5. The conversation history is updated in the memory for future context.

Use Cases

  • Task-oriented conversational AI systems

  • Complex query resolution requiring multiple steps or tool usage

  • Virtual assistants capable of performing actions or retrieving information

  • Customer support systems for technical or multi-step inquiries

  • Research and analysis assistants

  • Interactive documentation or FAQ systems

Special Features

  • Function Calling: Utilizes advanced chat models’ function calling for precise tool selection and execution.

  • Memory Management: Maintains conversation history for contextual understanding.

  • Tool Integration: Can use a variety of tools to enhance its capabilities and perform actions.

  • Moderation: Can implement input moderation to ensure safe interactions.

  • Vision Support: If the chat model supports vision capabilities, the agent can process and respond to image inputs.

  • Streaming: Supports streaming responses for real-time interaction.

  • Customizable Prompts: Allows for custom chat prompt templates to tailor the agent’s behavior.

Notes

  • The agent uses a sophisticated prompt structure to maintain consistent behavior.

  • It can handle multi-modal inputs if the underlying chat model supports it (e.g., text and images).

  • The system message can be customized to tailor the agent’s personality and capabilities.

  • The max iterations parameter can be used to control the depth of the agent’s problem-solving attempts.

  • This agent is particularly useful for scenarios where maintaining conversation context, using specific tools, and leveraging function calling capabilities are important.

The Tool Agent node provides a powerful solution for building AI systems that can engage in informed, context-aware conversations while having the ability to use tools as needed. Its combination of conversational abilities, tool usage, and function calling makes it suitable for a wide range of applications requiring both knowledge access and task execution within a conversational framework.