https://github.com/anuj0918/data-science-task
Data science Technical Writer Task
https://github.com/anuj0918/data-science-task
llama-index python sql sqlite
Last synced: about 2 months ago
JSON representation
Data science Technical Writer Task
- Host: GitHub
- URL: https://github.com/anuj0918/data-science-task
- Owner: Anuj0918
- Created: 2025-03-12T11:24:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-12T14:37:10.000Z (over 1 year ago)
- Last Synced: 2025-03-12T14:45:34.875Z (over 1 year ago)
- Topics: llama-index, python, sql, sqlite
- Language: Python
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RAG and Text-to-SQL Query in Single Interface
This project builds a RAG and Text-to-SQL query app in a single interface. We use:
- **OpenAI** to power the LLM capabilities
- **LlamaIndex** for orchestrating the RAG app
- **SQL Database** for storing and processing data from CSV files.
- **Streamlit** Provides an interactive and user-friendly UI.
## ๐งต Twitter Thread
**[X Thread](https://typefully.com/t/EJEGoEp)**
---
## ๐ Installation and Setup
## 1๏ธ. Setup OpenAI and LlamaCloud
Get an API key from [OpenAI](https://openai.com) and set it in the `.env` file:
Get an API key from [Llama Cloud](https://www.llama.cloud) and set it in the `.env` file:
```ini
OPENAI_API_KEY="your-openai-api-key"
name="your-llama-cloud-index-name"
project_name="your-llama-cloud-project-name"
organization_id="your-llama-cloud-organization-id"
api_key="your-llama-cloud-api-key"
```
## 2. Install Dependencies and Run the App
```ini
pip install streamlit llama-index openai sqlalchemy python-dotenv nest-asyncio
```
## How to Use
1. **Upload a CSV file** using the file uploader in the main interface.
2. **Ask questions** in natural language in the text input field, such as:
- "Tell me about the history of Los Angeles City."
- "Which states have cities with populations over 1 million?"
3. The application will **automatically determine** whether to use SQL or RAG to answer your question and display the results.
### How It Works:
The system **routes queries** between:
- **Text-to-SQL Tool** โ Translates natural language into SQL queries for structured data analysis.
- **Llama Cloud RAG Tool** โ Retrieves information from a knowledge base for contextual answers.
```ini
streamlit run app.py
```