Download README.md from Shiverion/Data-analysis-using-OpenAI-Assistant: direct link, hf CLI and curl.
- Browser
- Download file 2.76 kB
-
https://huggingface.co/spaces/Shiverion/Data-analysis-using-OpenAI-Assistant/resolve/main/README.md
- Command line
-
hf download hf://spaces/Shiverion/Data-analysis-using-OpenAI-Assistant/README.md
-
curl -L -o README.md https://huggingface.co/spaces/Shiverion/Data-analysis-using-OpenAI-Assistant/resolve/main/README.md
A newer version of the Gradio SDK is available: 6.29.1
title: Data Analyst Agent with OpenAI Assistants
emoji: π
colorFrom: blue
colorTo: red
sdk: gradio
python_version: '3.11'
app_file: app.py
pinned: false
π€ Data Analyst Agent with OpenAI Assistants
This project demonstrates a powerful data analysis agent built using the official OpenAI Assistants API. The agent leverages the built-in Code Interpreter tool to analyze user-uploaded CSV files, answer questions, and generate visualizations.
The web interface is created with Gradio, and the project environment is managed by uv.
π How to Use the Live Demo
- Upload a CSV File: Use the file uploader to select a
.csvfile from your computer. - Ask a Question: In the textbox, ask a question about your data in plain English. For example:
- "What is the average age in the dataset?"
- "Create a pie chart showing the distribution of categories."
- "What are the key insights from this data? Provide one recommendation."
- Run Analysis: Click the "Run Analysis" button. The agent will process your file and question on OpenAI's servers and return a detailed text answer along with any generated plots.
π οΈ Local Setup and Execution (For Developers)
Follow these steps to run the application on your own machine.
1. Clone the Repository
git clone [https://github.com/Shiverion/Data-analysis-using-OpenAI-Assistant.git](https://github.com/Shiverion/Data-analysis-using-OpenAI-Assistant.git)
cd your-repo-name
- Set Up the Environment with uv This project uses uv for fast and reproducible environment management.
First, install uv if you haven't already:
On macOS / Linux
curl -LsSf [https://astral.sh/uv/install.sh](https://astral.sh/uv/install.sh) | sh
On Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Then, sync the environment. This command creates a virtual environment and installs the exact package versions from the uv.lock file.
uv sync
3. Set Up Your API Key
Create a file named .env in the root of the project and add your OpenAI API key to it:
OPENAI_API_KEY='your-secret-key-here'
4. Run the Application
Use uv to run the app within the managed environment:
uv run app.py
Open the local URL (e.g., http://127.0.0.1:7860) in your browser.
π File Structure
app.py: The main Gradio application script containing the agent logic.
requirements.txt: A list of Python dependencies for Hugging Face Spaces.
uv.lock: A definitive lockfile for reproducible environments with uv.
.env: Local file for storing your secret API key (ignored by Git).
.gitignore: Specifies files for Git to ignore.