Tool Calling Agent
⚠️ DEPRECATION WARNING
This component is deprecated and will be removed in a future version of Nappai. Please migrate to the recommended alternative components.
General Overview
Tool Calling Agent is a smart AI helper in Nappai that can perform complex tasks by using external tools. It acts like an assistant that not only answers your questions but also decides when to use tools (like checking the current time or fetching data) to help you. This component supports conversation history, so it remembers previous messages, making it perfect for building chatbots and automated workflows where the AI thinks step-by-step.
How it Works
This component works by connecting a Language Model (LLM) to the agent. When a user provides a prompt or message, the agent analyzes the request. It can decide to use connected tools to gather information or perform actions. The agent processes this information, potentially using multiple steps to reason through the task, and generates a final response. It also maintains the chat history to ensure the conversation stays coherent over time.
Inputs
Input Fields
The following fields are available to configure this component. Each field may be visible in different operations:
- Chat History: Keeps track of previous messages to maintain context in multi-turn conversations.
- Model [REQUIRED]: The language model used for the agent’s reasoning and text generation. This connection is mandatory for the component to function.
- Tools: External tools that the agent can use to perform specific actions or fetch data.
- Disable Streaming: Disable streaming for the LLM.
- Early Stopping Method: Early stopping method to use for the agent.
- Executor Name: The name of the executor to use.
- Handle Parse Errors: Handles parsing errors during execution.
- Input: The user’s input or request.
- Max Iterations: Limits the maximum number of steps the agent can take to solve a task.
- System Prompt: A system prompt that defines the agent’s behavior and tone.
- Prompt: The user prompt template. This must contain the key ‘input’.
- Verbose: Enables verbose logging to show detailed steps of the agent’s process.
Outputs
This component produces an agent executor object and a response message. You can use the agent executor to run tasks in your workflow, or use the response to pass information to other components.
Output Data Example (JSON)json
{ “Agent”: { “type”: “AgentExecutor”, “description”: “The configured agent executor ready to process inputs and tools.” }, “Response”: { “type”: “Message”, “content”: “The current date and time is 2024-05-20 14:30:00.” } }
Connectivity
This component is typically connected as follows:
- Model: Connect a Language Model (LLM) component here. This is required for the agent to work.
- Tools: Connect Tool components here to give the agent capabilities like fetching data, running calculations, or calling APIs.
- Chat History: Connect to previous chat history outputs if you are building a multi-turn conversation flow.
- Input: Connect a text input or previous text output that contains the user’s query.
- Response: Use the output to display results to users or pass data to downstream components.
Usage Example
Scenario: Creating an AI assistant that can answer questions and check the current time.
- Drag the Tool Calling Agent into your workflow.
- Connect a Chat Model to the Model input.
- Connect a Current Datetime Tool to the Tools input.
- Set the System Prompt to “You are a helpful assistant.”
- Connect a Text Input to the Input field with a message like “What time is it?”
- When you run the workflow, the agent will check the time using the tool and return the result in the Response output.
Important Notes
🔒 Dangerous Code Execution Enabled 🔴 The component allows execution of arbitrary code through tools. Use only trusted tools and data, and be cautious if exposing this component to untrusted inputs.
⚠️ User Prompt Requires {input} 🟢
The user prompt field must include the placeholder {input}. If it is missing, the agent will not receive the user’s input and will fail to generate a response.
📋 LLM Must Be Provided 🟢 You need to connect a language model to the component for it to function. Without an LLM, the agent cannot generate responses or call tools.
💡 Set a Custom System Prompt 🟢 Use the system prompt to guide the agent’s behavior (e.g., “You are a helpful assistant”). Tailoring the prompt can improve relevance and tone of responses.
💡 Include Relevant Chat History 🟡 Providing previous messages in the chat history helps the agent maintain context. This can improve coherence, especially in multi-turn conversations.
⚙️ Enable Streaming for Real-Time Output 🟢 Turn off the “Disable Streaming” option to receive incremental responses from the LLM. This can make the agent feel faster, especially for longer replies.
⚙️ Adjust Early Stopping Method 🟡 The early stopping method controls when the agent stops generating. Options are None, generate, and force. Choose carefully to avoid premature termination or endless loops.
ℹ️ Agent May Stop Early With ‘force’ Method 🟡 If the early stopping method is set to ‘force’, the agent will halt even if tool calls are still pending. This can leave tasks incomplete.
ℹ️ Automatic GetCurrentDatetime Tool 🟢 A tool that returns the current date and time is always available. You can use it without adding it manually, simplifying time-related queries.
Tips and Best Practices
- Always ensure the Model is connected; the agent will not work without a language model.
- Remember to include
{input}in your prompt templates so the agent can receive user messages. - Use trusted tools only, as the component can execute code via tools.
- Enable streaming for a better user experience with longer responses.
- Customize the System Prompt to define the agent’s personality and constraints.
Security Considerations
This component supports code execution through tools. To maintain security:
- Only use tools from trusted sources.
- Avoid passing untrusted user inputs directly to tools that execute code.
- Review the tools connected to the agent to ensure they do not expose sensitive data or perform risky actions.