Skip to content

Latest commit

 

History

History
82 lines (70 loc) · 2.84 KB

File metadata and controls

82 lines (70 loc) · 2.84 KB

Gradio-Based CSV Question Answering and Visualization Application

Overview

This project is a Gradio-based application that enables users to upload CSV files, ask questions about their contents, and receive answers generated by a local Large Language Model (LLM). The application also supports data visualization, where users provide specific details for graph generation.

Solution Architecture

The application processes user queries using an LLM-powered agent. The LLM generates a structured response that includes:

  • A Python script (filter_script) to compute the answer from the CSV data.

Users now have full control over visualization, specifying:

  • The Graph Type (e.g., bar chart, line plot, scatter plot)
  • X-axis label and Y-axis label (these are adjustable parameters)

Future Scope

  • Automated Visualization Decisions: Explore AI-assisted recommendations for graph types.
  • Enhanced Query Processing: Improve AI’s ability to interpret complex queries.
  • Multi-File Support: Enable querying across multiple CSVs.
  • Advanced Filtering Logic: Introduce more complex data transformations.

Features

  • CSV File Handling
    • Upload and validate CSV files
    • Handle parsing errors gracefully
  • Question Answering
    • Accepts both textual and numerical queries
    • Uses Cohere’s LLM for local execution
    • Implements structured query processing using Pydantic AI
  • Graph Plotting & Visualization
    • Users must specify the graph type
    • X-axis and Y-axis labels are adjustable
    • Display plots within the Gradio interface

Tech Stack

  • Backend: Python, Cohere, Pydantic AI, Pandas, Matplotlib
  • Frontend: Gradio
  • LLM Model: Cohere Command R+ (configurable)

Installation

Prerequisites

Ensure you have Python installed (>=3.8) and a Cohere API key.

Steps

  1. Sign up for Cohere and get an API key from Cohere’s platform.
  2. Clone the repository:
    git clone <repo-url>
    cd <repo-folder>
  3. Install dependencies:
    pip install -r requirements.txt
  4. Run the application:
    python main.py

Configuration

Modify config.yml to adjust the LLM settings:

Agent:
  model_name: "command-r-plus"
  api_key: 'COHERE_API_KEY'

Usage

  1. Upload a CSV file through the Gradio interface.
  2. Enter a question related to the dataset (e.g., "What is the average price?").
  3. The LLM generates a Python script to compute the answer from the CSV.
  4. If visualization is required, provide:
    • Graph Type (e.g., bar, line, scatter)
    • X-axis label and Y-axis label (these can be adjusted as needed)
  5. View the response and visualization (if applicable) directly in the Gradio UI.

Testing

Run tests using:

pytest test/

License

This project is open-source and available under the MIT License.