csv-agent / README.md
NaderAfshar
fixed a type on the screenshot.JPG
83b4de7
---
title: Csv Agent
emoji: 🐒
colorFrom: green
colorTo: gray
sdk: gradio
sdk_version: 5.15.0
app_file: app.py
pinned: false
license: mit
short_description: A sample Agentic Data Analyst
---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
# πŸ“Š CSV Agent with Cohere LLM and Langchain
This application is developed as a demonstration of an Agentic system that acts as
a Data Analyst. A csv file can be loaded and analyzed by asking questions. Charts can also
be requested and should be displayed by the agent.
The underlying LLM is a **Cohere Command-R** model, specifically **command-r-plus-08-2024**. The
Agent also makes use of the LangChain framework.
## 🎯 Key Features
- **Dynamic CSV Upload:** Upload your CSV file effortlessly for instant analysis.
- **Natural Language Queries:** Ask questions in plain English, and the agent responds with data insights.
- **Chart Generation:** Visualize your data with auto-generated charts based on your queries.
- **Interactive Interface:** User-friendly interface built with Gradio for easy interaction.
- **Agent Reset:** Quickly reset the agent to upload new datasets without refreshing the page.
## πŸ—‚οΈ Installation
1. Clone the repository:
```bash
git clone https://huggingface.co/spaces/nader01/csv-agent
cd csv-agent
```
2. Create a virtual environment and activate it:
```bash
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
```
3. Install dependencies:
```bash
pip install -r requirements.txt
```
4. Set up your `.env` file with the Cohere API key:
```bash
COHERE_API_KEY=your_cohere_api_key
```
5. Run the application:
```bash
python csv_agent_with_chart.py
```
## 🌐 How to Use
1. **Upload a CSV File:**
- Click on the **Upload CSV** button.
- Select your CSV file to load the data.
- View a preview of your data.
2. **Ask a Question:**
- Enter your question in the **Ask a Question** box.
- Click **Submit Question** to receive a detailed answer.
3. **View Charts:**
- If the response includes a chart, it will be displayed below the response box.
4. **Reset Agent:**
- Click **Reset Agent** to clear data and upload a new CSV file without refreshing the page.
## 🎨 User Interface Design
- **Input & Output Boxes:** Light blue background with bold, dark blue labels for easy readability.
- **Interactive Elements:** Buttons with responsive feedback for better user experience.
![UI Screenshot](ui_screenshot.JPG)
## 🧠 Powered By
- **Cohere AI:** For natural language processing and data analysis.
- **Gradio:** For building the interactive user interface.
- **Pandas:** For efficient data handling.
## πŸ“œ License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
---
Enjoy exploring your data with this **CSV Agent**! πŸš€