Skip to content

Commit 0ba9728

Browse files
authored
Merge pull request #4 from pranitab07/AI
Finalized exe and created distribution package
2 parents d80f194 + 50bb814 commit 0ba9728

34 files changed

Lines changed: 294 additions & 160 deletions

.env.example

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Groq API Key for LLM
2+
GROQ_API_KEY=your_groq_api_key_here
3+
4+
# Database Configuration (used in db_config.yaml)
5+
DB_PASSWORD=your_database_password
6+
DB_NAME=your_database_name
7+
8+
# Vector Store Configuration (if using Pinecone)
9+
PINECONE_API_KEY=your_pinecone_api_key_here
10+
11+
# MLflow Configuration (optional)
12+
MLFLOW_TRACKING_URI=http://127.0.0.1:5000

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ coverage.xml
5656
*.log
5757

5858
# Sphinx documentation
59+
docs/
5960
docs/_build/
6061

6162
# PyBuilder
@@ -67,6 +68,7 @@ target/
6768
# Database
6869
*.db
6970
*.rdb
71+
db_config.yaml
7072

7173
# Pycharm
7274
.idea
@@ -91,4 +93,9 @@ target/
9193
*.swo
9294

9395
# Mypy cache
94-
.mypy_cache/
96+
.mypy_cache/
97+
98+
BUILD.md
99+
SETUP_INSTRUCTIONS.md
100+
CHANGES_AND_NEXT_STEPS.md
101+
.claude/

Docker-Compose.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77
PROJECT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
88
BUCKET = [OPTIONAL] your-bucket-for-syncing-data (do not include 's3://')
99
PROFILE = default
10-
<<<<<<< HEAD
11-
PROJECT_NAME = sql_query_completion
12-
=======
13-
PROJECT_NAME = sql_code_completion
14-
>>>>>>> main
10+
PROJECT_NAME = query_pilot
1511
PYTHON_INTERPRETER = python3
1612

1713
ifeq (,$(shell which conda))

README.md

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,29 +103,44 @@ pip install -r requirements.txt
103103
```
104104

105105
### 4. Set Up Environment Variables
106-
107-
Create a `.env` file in the project root:
108-
106+
107+
Copy the example environment file and configure it:
108+
109+
```bash
110+
cp .env.example .env
111+
```
112+
113+
Edit `.env` file with your credentials:
114+
109115
```env
110116
GROQ_API_KEY=your_groq_api_key_here
117+
DB_PASSWORD=your_database_password
118+
DB_NAME=your_database_name
111119
PINECONE_API_KEY=your_pinecone_api_key_here # Optional, only for Pinecone
112-
PINECONE_ENVIRONMENT=your_pinecone_env_here # Optional, only for Pinecone
113120
```
114-
121+
115122
### 5. Configure Database Connection
116-
117-
Edit `db_config.yaml` with your database credentials:
118-
123+
124+
Copy the example database config and configure it:
125+
126+
```bash
127+
cp db_config.yaml.example db_config.yaml
128+
```
129+
130+
The `db_config.yaml` file uses environment variables for sensitive data:
131+
119132
```yaml
120133
db:
121134
type: mysql # or postgres
122-
user: your_username
123-
password: your_password
135+
user: root
136+
password: ${DB_PASSWORD} # Reads from .env
124137
host: localhost
125138
port: 3306 # 5432 for PostgreSQL
126-
name: your_database_name
139+
name: ${DB_NAME} # Reads from .env
127140
sample_rows: 2
128141
```
142+
143+
**Note**: The actual `db_config.yaml` file is gitignored for security. Always use the template file as a reference.
129144

130145
### 6. Download and Prepare Data
131146

SETUP_INSTRUCTIONS.md

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
# QueryPilot Setup Instructions
2+
3+
Thank you for downloading QueryPilot! Follow these simple steps to get started.
4+
5+
## Prerequisites
6+
7+
Before you begin, make sure you have:
8+
9+
- ✅ Windows 10 or higher
10+
- ✅ MySQL Workbench or pgAdmin 4 installed
11+
- ✅ An active database (MySQL or PostgreSQL)
12+
- ✅ Groq API key (free at https://console.groq.com)
13+
- ✅ Pinecone API key (optional, only if using Pinecone vector store)
14+
15+
## Quick Start (5 minutes)
16+
17+
### Step 1: Configure Environment Variables
18+
19+
1. Locate the file named `.env.example` in this folder
20+
2. Rename it to `.env` (remove the `.example` extension)
21+
3. Open `.env` with a text editor (Notepad, VS Code, etc.)
22+
4. Fill in your credentials:
23+
24+
```env
25+
GROQ_API_KEY=your_groq_api_key_here
26+
DB_PASSWORD=your_database_password
27+
DB_NAME=your_database_name
28+
PINECONE_API_KEY=your_pinecone_key_here # Only if using Pinecone
29+
```
30+
31+
**Where to get API keys:**
32+
- **Groq API Key**: Sign up at https://console.groq.com (free tier available)
33+
- **Pinecone API Key**: Sign up at https://www.pinecone.io (only if using Pinecone vector store)
34+
35+
### Step 2: Configure Database Connection
36+
37+
1. Locate the file named `db_config.yaml.example`
38+
2. Rename it to `db_config.yaml`
39+
3. Open `db_config.yaml` and verify the settings:
40+
41+
```yaml
42+
db:
43+
type: mysql # Change to 'postgres' if using PostgreSQL
44+
user: root # Your database username
45+
password: ${DB_PASSWORD} # Uses value from .env
46+
host: localhost
47+
port: 3306 # Use 5432 for PostgreSQL
48+
name: ${DB_NAME} # Uses value from .env
49+
sample_rows: 2
50+
```
51+
52+
**Note**: The `${DB_PASSWORD}` and `${DB_NAME}` placeholders will automatically use the values you set in the `.env` file.
53+
54+
### Step 3: Run QueryPilot
55+
56+
1. Double-click `QueryPilot.exe`
57+
2. You should see: `👀 Listening for Ctrl+C and Tab... (press Esc to quit)`
58+
3. **Success!** QueryPilot is now running.
59+
60+
## How to Use QueryPilot
61+
62+
### Step 1: Open Your SQL Editor
63+
64+
Open MySQL Workbench or pgAdmin 4 (must be one of these)
65+
66+
### Step 2: Ask Query using comments
67+
68+
Ask your question:
69+
70+
```sql
71+
-- Fetch me the data for employees having more than 20LPA CTC
72+
```
73+
74+
### Step 3: Get AI Suggestions
75+
76+
1. Select your question (comment)
77+
2. Press **Ctrl+C** to trigger QueryPilot
78+
3. Wait a moment for the AI suggestion to appear
79+
80+
### Step 4: Accept or Dismiss
81+
82+
- Press **Tab** to accept and insert the suggestion
83+
- Press any other key to dismiss it
84+
85+
### Other Hotkeys
86+
87+
- **Ctrl+Z**: Remove ghost text
88+
- **Ctrl+Shift+C**: Clear session memory
89+
- **Esc**: Quit QueryPilot
90+
91+
## Example Workflow
92+
93+
```sql
94+
-- 1. Ask your question
95+
-- Fetch me the data for employees having more than 20LPA CTC
96+
97+
-- 2. Select the statement and press Ctrl+C
98+
99+
-- 3. QueryPilot shows suggestion:
100+
/* suggestion: SELECT * FROM Employees WHERE CTC > 2000000; */
101+
102+
-- 4. Press Tab to accept, or any other key to dismiss
103+
```
104+
105+
## Configuration (Optional)
106+
107+
You can customize QueryPilot by editing `params.yaml`:
108+
109+
### Change Vector Store
110+
111+
```yaml
112+
vector_store:
113+
type: faiss # Options: faiss, pinecone, chromadb
114+
```
115+
116+
### Adjust Session Memory
117+
118+
```yaml
119+
memory:
120+
enable: true
121+
limit: 3 # Remember last 3 queries
122+
```
123+
124+
### Change Hotkeys
125+
126+
```yaml
127+
triggers:
128+
initiater: ctrl+c # Change trigger key
129+
filler: tab # Change accept key
130+
```
131+
132+
## Troubleshooting
133+
134+
### Problem: "Cannot find .env file"
135+
136+
**Solution:**
137+
- Make sure you renamed `.env.example` to `.env`
138+
- Ensure `.env` is in the same folder as `QueryPilot.exe`
139+
- Check that the file extension is `.env` (not `.env.txt`)
140+
141+
### Problem: "Database connection failed"
142+
143+
**Solution:**
144+
1. Verify your database is running
145+
2. Check credentials in `.env` file
146+
3. Make sure the database name exists
147+
4. Test connection with MySQL Workbench/pgAdmin 4 first
148+
149+
### Problem: "API key invalid"
150+
151+
**Solution:**
152+
1. Verify your Groq API key at https://console.groq.com
153+
2. Make sure there are no extra spaces in the `.env` file
154+
3. Check that you copied the entire key
155+
156+
### Problem: "Vector store not found"
157+
158+
**Solution:**
159+
160+
If you see errors about missing vector store files, you need to prepare the data:
161+
162+
**Option A - Use Pre-built Data (if provided):**
163+
- Check if `data/processed/` folder exists with vector store files
164+
- If not, see Option B
165+
166+
**Option B - Build Vector Store Yourself:**
167+
168+
This requires Python 3.8+. In a terminal:
169+
170+
```bash
171+
# Install Python dependencies
172+
pip install -r requirements.txt
173+
174+
# Download SQL dataset
175+
python src/loading_data.py --config params.yaml
176+
177+
# Build vector store
178+
python src/build_vector_stores.py --config params.yaml
179+
```
180+
181+
### Problem: Antivirus is blocking QueryPilot.exe
182+
183+
**Solution:**
184+
- This is a false positive (common with packaged Python apps)
185+
- Add an exception for `QueryPilot.exe` in your antivirus settings
186+
- The exe is safe - it's just Python code packaged with PyInstaller
187+
188+
### Problem: Suggestions are not appearing
189+
190+
**Solution:**
191+
1. Make sure MySQL Workbench or pgAdmin 4 is the active window
192+
2. Check that you pressed Ctrl+C (not just C)
193+
3. Verify QueryPilot terminal shows "SQL Captured"
194+
4. Try again with a different SQL query
195+
196+
### Problem: "Missing DLL" errors
197+
198+
**Solution:**
199+
- Install Visual C++ Redistributable: https://aka.ms/vs/17/release/vc_redist.x64.exe
200+
- Restart your computer after installation
201+
202+
## Performance Tips
203+
204+
- **Faster suggestions**: Use FAISS vector store (default)
205+
- **Better suggestions**: Increase `vector_store.top_k` in `params.yaml`
206+
- **More context**: Increase `memory.limit` to remember more queries
207+
208+
## Need More Help?
209+
210+
- **Full Documentation**: See `README.md` in this folder
211+
- **Report Issues**: Contact the developer or check the project repository
212+
213+
---
214+
215+
**Enjoy using QueryPilot! Happy querying! 🚀**

db_config.yaml

Lines changed: 0 additions & 8 deletions
This file was deleted.

db_config.yaml.example

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
db:
2+
type: mysql # Change to 'postgres' if using PostgreSQL
3+
user: root # Your database username
4+
password: ${DB_PASSWORD} # Uses value from .env
5+
host: localhost
6+
port: 3306 # Use 5432 for PostgreSQL
7+
name: ${DB_NAME} # Uses value from .env
8+
sample_rows: 2

dockerfile

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)