Skip to content

CSVAgent

⚠️ DEPRECATION WARNING

This component is deprecated and will be removed in a future version of Nappai. Please migrate to the recommended alternative components.

The CSVAgent lets you turn a CSV file into an interactive AI assistant. By feeding the file and a language model, the agent can answer questions, filter rows, or perform calculations directly on the data.

How it Works

The component uses LangChain’s create_csv_agent function to build an agent that can read a CSV file and use a language model (LLM) to understand and answer queries about that data.

  • Model – The LLM that powers the agent’s reasoning.
  • File Path – The location of the CSV file you want the agent to work with.
  • Agent Type – Determines how the agent interprets your questions.
    • zero‑shot-react-description – The agent explains its plan before acting.
    • openai-functions – Uses OpenAI’s function calling to perform actions.
    • openai-tools – Uses a set of predefined tools for CSV manipulation.
      The agent is wrapped with an asynchronous callback handler so that its progress can be shown in the Nappai dashboard in real time.

Inputs

  • Model – Select the language model that will drive the agent’s responses.
  • File Path – Browse or type the path to the CSV file you want the agent to read.
  • Agent Type – Choose the style of interaction the agent will use.
  • Handle Parse Errors – Decide whether the agent should try to recover from parsing problems in the CSV.
  • Input – Provide any additional text or prompts that the agent should consider when answering.
  • Max Iterations – Set how many reasoning steps the agent can take before giving up.
  • Verbose – Turn on detailed logging to see the agent’s internal thought process.

Outputs

  • Agent – The fully configured AgentExecutor that can be run to process queries.
  • Response – The text message returned by the agent after executing a query.

Usage Example

  1. Drag the CSVAgent component onto your workflow.
  2. Upload a CSV file (e.g., sales_data.csv).
  3. Select a language model such as OpenAI GPT‑4.
  4. Choose Agent Type openai-tools.
  5. Click Run.
  6. In the next component, send a prompt like “Show me the top 5 rows where sales > 1000.”
  7. The agent will read the CSV, apply the filter, and return the requested rows.
  • LCAgentComponent – The base component that provides common agent functionality.
  • CSVTool – A tool that can be added to other agents for CSV manipulation.
  • FileReader – Reads files from various sources; useful if you need to preprocess the CSV before passing it to the agent.

Tips and Best Practices

  • Keep the CSV file size moderate; very large files may slow down the agent.
  • Use the openai-tools agent type for quick, tool‑based queries.
  • Enable Verbose only when debugging to avoid cluttering logs.
  • If you encounter parsing errors, try the Handle Parse Errors option or clean the CSV beforehand.

Security Considerations

  • Ensure the CSV file does not contain sensitive personal data unless you have proper access controls.
  • The agent reads the file locally; no data is sent to external services unless the chosen LLM is hosted on a cloud API.
  • Use secure file paths and permissions to prevent unauthorized access to the CSV.