Spaces:
Sleeping
Sleeping
Merge branch 'main' into NL2SQL-V1.0
Browse files- .env +0 -1
- .vscode/settings.json +3 -0
- .gitignore β backend/.gitignore +0 -0
- backend/app/main.py +38 -0
- hf_evaluation_results.json β backend/hf_evaluation_results.json +0 -0
- hf_test_bench.py β backend/hf_test_bench.py +2 -2
- requirements.txt β backend/requirements.txt +0 -0
- {src β backend/src}/database/Chinook_Sqlite.sqlite +0 -0
- {src β backend/src}/database/db_manager.py +0 -0
- {src β backend/src}/nl2sql/hf_engine.py +0 -0
- {src β backend/src}/nl2sql/sql_agent.py +2 -2
- {src β backend/src}/scripts/evaluation_mode.py +0 -0
- {src β backend/src}/scripts/interactive_mode.py +0 -0
- {src β backend/src}/scripts/taxonomy_report.py +0 -0
- {src β backend/src}/scripts/test_cases.json +0 -0
- frontend/App.vue +0 -0
- src/nl2sql/__pycache__/qwen_engine.cpython-313.pyc +0 -0
- src/scripts/__pycache__/evaluate.cpython-313.pyc +0 -0
- src/scripts/__pycache__/evaluate_hf.cpython-313.pyc +0 -0
.env
DELETED
|
@@ -1 +0,0 @@
|
|
| 1 |
-
HF_TOKEN='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'
|
|
|
|
|
|
.vscode/settings.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"postman.settings.dotenv-detection-notification-visibility": false
|
| 3 |
+
}
|
.gitignore β backend/.gitignore
RENAMED
|
File without changes
|
backend/app/main.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Path: app/main.py
|
| 2 |
+
# Main entry point for the NL2SQL application
|
| 3 |
+
import os
|
| 4 |
+
from dotenv import load_dotenv
|
| 5 |
+
from backend.src.scripts.interactive_mode import run_interactiveMode
|
| 6 |
+
from backend.src.scripts.evaluation_mode import run_evaluation
|
| 7 |
+
|
| 8 |
+
load_dotenv()
|
| 9 |
+
# Load HuggingFace API token from environment variable
|
| 10 |
+
hf_token = os.getenv("HF_TOKEN")
|
| 11 |
+
if not hf_token:
|
| 12 |
+
raise ValueError("HuggingFace API token not found!")
|
| 13 |
+
|
| 14 |
+
def main():
|
| 15 |
+
"""Main application entry point and interactive menu"""
|
| 16 |
+
while True:
|
| 17 |
+
print("\n" + "="*30)
|
| 18 |
+
print(" NL2SQL Application Main Menu")
|
| 19 |
+
print("\n" + "="*30)
|
| 20 |
+
print("1. Run Interactive Agent NL2SQL Mode (Ask a single question)")
|
| 21 |
+
print("2. Run Batch Evaluation of NL2SQL Agent (Evaluate on 15 test cases)")
|
| 22 |
+
print("3. Exit")
|
| 23 |
+
print("\n" + "="*30)
|
| 24 |
+
|
| 25 |
+
choice = input("Select an option (1-3): ")
|
| 26 |
+
|
| 27 |
+
if choice == '1':
|
| 28 |
+
run_interactiveMode()
|
| 29 |
+
elif choice == '2':
|
| 30 |
+
run_evaluation()
|
| 31 |
+
elif choice == '3':
|
| 32 |
+
print("Exiting application. Goodbye!")
|
| 33 |
+
break
|
| 34 |
+
else:
|
| 35 |
+
print("Invalid choice. Please select a valid option (1, 2, or 3).")
|
| 36 |
+
|
| 37 |
+
if __name__ == "__main__":
|
| 38 |
+
main()
|
hf_evaluation_results.json β backend/hf_evaluation_results.json
RENAMED
|
File without changes
|
hf_test_bench.py β backend/hf_test_bench.py
RENAMED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
# Test the Hugging Face inference
|
| 2 |
-
from src.nl2sql.hf_engine import generate_sql
|
| 3 |
-
from src.database.db_manager import get_db_connection, get_schema_context
|
| 4 |
import pandas as pd
|
| 5 |
|
| 6 |
def test_single_query():
|
|
|
|
| 1 |
# Test the Hugging Face inference
|
| 2 |
+
from backend.src.nl2sql.hf_engine import generate_sql
|
| 3 |
+
from backend.src.database.db_manager import get_db_connection, get_schema_context
|
| 4 |
import pandas as pd
|
| 5 |
|
| 6 |
def test_single_query():
|
requirements.txt β backend/requirements.txt
RENAMED
|
File without changes
|
{src β backend/src}/database/Chinook_Sqlite.sqlite
RENAMED
|
File without changes
|
{src β backend/src}/database/db_manager.py
RENAMED
|
File without changes
|
{src β backend/src}/nl2sql/hf_engine.py
RENAMED
|
File without changes
|
{src β backend/src}/nl2sql/sql_agent.py
RENAMED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
# Path: src/nl2sql/sql_agent.py
|
| 2 |
# SQL Agent for handling NL2SQL conversion with Auto-Correct functionality
|
| 3 |
-
from src.database.db_manager import get_db_connection, get_schema_context
|
| 4 |
from langchain_core.prompts import PromptTemplate
|
| 5 |
-
from src.nl2sql.hf_engine import get_llm
|
| 6 |
|
| 7 |
# Craft the Prompt Template to instruct LLM on its persona
|
| 8 |
SQL_PROMPT_TEMPLATE = """You are an expert SQLite developer.
|
|
|
|
| 1 |
# Path: src/nl2sql/sql_agent.py
|
| 2 |
# SQL Agent for handling NL2SQL conversion with Auto-Correct functionality
|
| 3 |
+
from backend.src.database.db_manager import get_db_connection, get_schema_context
|
| 4 |
from langchain_core.prompts import PromptTemplate
|
| 5 |
+
from backend.src.nl2sql.hf_engine import get_llm
|
| 6 |
|
| 7 |
# Craft the Prompt Template to instruct LLM on its persona
|
| 8 |
SQL_PROMPT_TEMPLATE = """You are an expert SQLite developer.
|
{src β backend/src}/scripts/evaluation_mode.py
RENAMED
|
File without changes
|
{src β backend/src}/scripts/interactive_mode.py
RENAMED
|
File without changes
|
{src β backend/src}/scripts/taxonomy_report.py
RENAMED
|
File without changes
|
{src β backend/src}/scripts/test_cases.json
RENAMED
|
File without changes
|
frontend/App.vue
ADDED
|
File without changes
|
src/nl2sql/__pycache__/qwen_engine.cpython-313.pyc
DELETED
|
Binary file (2.4 kB)
|
|
|
src/scripts/__pycache__/evaluate.cpython-313.pyc
DELETED
|
Binary file (3.31 kB)
|
|
|
src/scripts/__pycache__/evaluate_hf.cpython-313.pyc
DELETED
|
Binary file (5.03 kB)
|
|
|