ChartRAG is a web application that allows users to upload CSV files, generate data summaries, and ask questions about the data using OpenAI's language models. The application is built using Flask and provides an intuitive web interface for data interaction.
- CSV File Upload: Users can upload CSV files through the web interface. The application reads the file and processes the data using Pandas.
- Data Summary: The application generates a statistical summary of the uploaded data and uses OpenAI's API to create a natural language summary.
- Question and Answer: Users can ask questions about the data, and the application provides answers based on the data summary using OpenAI's models.
- Web Interface: The application includes HTML templates for uploading files and viewing data summaries and answers.
- Flask: A lightweight web framework for building the server and handling HTTP requests.
- Pandas: A data analysis library for reading and summarizing CSV files.
- OpenAI API: Used to generate data summaries and answer questions.
- Python-dotenv: For loading environment variables, including the OpenAI API key.
- Install Dependencies: Ensure you have Python installed, then run
pip install -r requirements.txtto install the necessary packages. - Environment Variables: Create a
.envfile in the root directory and add your OpenAI API key:OPENAI_API_KEY=your_openai_api_key - Run the Application: Start the Flask server by running
python app.py. Access the application in your web browser athttp://localhost:5000.
-
Clone the repository:
git clone <repository-url> cd chartRAG
-
Set up a virtual environment:
Make sure you have Python and pip installed. Then create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
With the virtual environment activated, run:
pip install -r requirements.txt
-
Set the OpenAI API Key:
You can set the OpenAI API key as an environment variable. Here are some methods:
-
On macOS/Linux with Bash or Zsh:
Add the following line to your
~/.bashrcor~/.zshrcfile:export OPENAI_API_KEY='your-api-key'
Reload your shell configuration:
source ~/.bashrc
or
source ~/.zshrc
-
On Windows with Command Prompt:
set OPENAI_API_KEY=your-api-key
-
On Windows with PowerShell:
$env:OPENAI_API_KEY='your-api-key'
-
Using a
.envFile:Create a file named
.envin your project directory and add:OPENAI_API_KEY=your-api-keyUse
python-dotenvto load the environment variables in yourapp.py:from dotenv import load_dotenv load_dotenv()
-
-
Run the application:
Start the Flask application:
python app.py
-
Access the application:
Open your web browser and go to
http://127.0.0.1:5000/to access the application.