OpenAI Tools Agent
⚠️ DEPRECATION WARNING
This component is deprecated and will be removed in a future version of Nappai. Please migrate to the recommended alternative components.
The OpenAI Tools Agent lets you ask an AI model to perform tasks by calling tools you provide. Think of it as a smart helper that can look up information, run calculations, or interact with other parts of your system while you chat with it.
How it Works
When you use this component, you give it a language model (like GPT‑4) and a list of tools. The component builds a conversation that starts with a system message (the “System Prompt”), then adds any past chat history, and finally sends the user’s question (the “Prompt”) to the model. The model decides which tool to use, calls it, and returns the result. The whole process is handled automatically, so you don’t need to write code for the tool calls.
Inputs
- Chat History – A list of previous messages that the agent can refer to.
- Model – The language model that will answer questions and decide which tool to use.
- Tools – A collection of tools that the agent can call.
- Disable Streaming – If checked, the model will send the full answer at once instead of streaming it.
- Handle Parse Errors – If checked, the agent will try to recover if a tool call fails.
- Input – The user’s question or request that will be sent to the model.
- Max Iterations – The maximum number of times the agent can loop through tool calls before giving up.
- System Prompt – A message that tells the model how it should behave (e.g., “You are a helpful assistant”).
- Prompt – The template for the user’s message; it must contain the placeholder
{input}
. - Verbose – If checked, the agent will log more detailed information for debugging.
Outputs
- Agent – The built agent object that can be reused in other parts of your workflow.
- Response – The final message from the agent after it has finished its task.
Usage Example
- Add the component to your dashboard.
- Connect a language model (e.g., GPT‑4) to the Model input.
- Add a tool such as a “Weather API” tool to the Tools input.
- Set the System Prompt to “You are a helpful assistant that can fetch weather data.”
- Enter a user question in the Input field, e.g., “What’s the weather in New York tomorrow?”
- Run the workflow. The agent will ask the Weather API tool for the data and return the answer.
The Response output will contain the final answer, which you can display in a chat window or pass to another component.
Related Components
- OpenAI LLM – Provides the language model used by the agent.
- Tool – Defines a single action the agent can call (e.g., a web request or a database query).
- Chat History – Stores previous messages for context.
Tips and Best Practices
- Keep the System Prompt short and clear; it sets the tone for all responses.
- Use the Prompt template to include dynamic data, such as
{input}
or{chat_history}
. - If you need more control over tool usage, consider using the newer “OpenAI Agent” component instead of this legacy version.
- Test with a small number of Max Iterations to avoid runaway loops.
Security Considerations
- Store your OpenAI API key securely in Nappai’s credential manager.
- Limit the tools you expose to the agent to only those that are necessary for the task.
- Review the data that the agent sends to external APIs to avoid accidental leaks of sensitive information.