Upload 9 files
Browse files- app.py +1 -1
- db/init_db.py +31 -4
- nlp/__pycache__/query_processor.cpython-312.pyc +0 -0
- nlp/__pycache__/sql_model.cpython-312.pyc +0 -0
- nlp/sql_model.py +1 -0
app.py
CHANGED
|
@@ -9,7 +9,7 @@ query_processor = QueryProcessor(db)
|
|
| 9 |
def respond(message, history):
|
| 10 |
"""Processes user queries, fetches results from the database, and returns responses."""
|
| 11 |
response = query_processor.process_query(message)
|
| 12 |
-
return response
|
| 13 |
|
| 14 |
# Gradio Chat UI
|
| 15 |
demo = gr.ChatInterface(
|
|
|
|
| 9 |
def respond(message, history):
|
| 10 |
"""Processes user queries, fetches results from the database, and returns responses."""
|
| 11 |
response = query_processor.process_query(message)
|
| 12 |
+
return response
|
| 13 |
|
| 14 |
# Gradio Chat UI
|
| 15 |
demo = gr.ChatInterface(
|
db/init_db.py
CHANGED
|
@@ -39,15 +39,42 @@ def initialize_database(db_name='chat_assistant.db'):
|
|
| 39 |
employees_data = [
|
| 40 |
(1, 'Alice', 'Sales', 50000, '2021-01-15'),
|
| 41 |
(2, 'Bob', 'Engineering', 70000, '2020-06-10'),
|
| 42 |
-
(3, 'Charlie', 'Marketing', 60000, '2022-03-20')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
]
|
| 44 |
cursor.executemany('INSERT INTO Employees VALUES (?, ?, ?, ?, ?)', employees_data)
|
| 45 |
|
| 46 |
# Insert sample data into Departments table
|
| 47 |
departments_data = [
|
| 48 |
-
(1, 'Sales', 'Alice'),
|
| 49 |
-
(2, 'Engineering', 'Bob'),
|
| 50 |
-
(3, 'Marketing', 'Charlie')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
]
|
| 52 |
cursor.executemany('INSERT INTO Departments VALUES (?, ?, ?)', departments_data)
|
| 53 |
cursor.execute("INSERT INTO table_metadata (table_name, description) VALUES ('Employees','Details of Employees in Department.')")
|
|
|
|
| 39 |
employees_data = [
|
| 40 |
(1, 'Alice', 'Sales', 50000, '2021-01-15'),
|
| 41 |
(2, 'Bob', 'Engineering', 70000, '2020-06-10'),
|
| 42 |
+
(3, 'Charlie', 'Marketing', 60000, '2022-03-20'),
|
| 43 |
+
(4, 'David', 'HR', 45000, '2019-11-05'),
|
| 44 |
+
(5, 'Eve', 'Finance', 65000, '2020-03-18'),
|
| 45 |
+
(6, 'Frank', 'IT', 72000, '2021-07-22'),
|
| 46 |
+
(7, 'Grace', 'Operations', 55000, '2022-01-10'),
|
| 47 |
+
(8, 'Hank', 'Customer Service', 48000, '2021-04-12'),
|
| 48 |
+
(9, 'Ivy', 'Sales', 51000, '2018-09-30'),
|
| 49 |
+
(10, 'Jack', 'Engineering', 80000, '2020-12-01'),
|
| 50 |
+
(11, 'Kim', 'Marketing', 77000, '2021-08-15'),
|
| 51 |
+
(12, 'Leo', 'HR', 50000, '2019-05-23'),
|
| 52 |
+
(13, 'Mona', 'Finance', 51000, '2022-02-17'),
|
| 53 |
+
(14, 'Nate', 'IT', 71000, '2020-07-07'),
|
| 54 |
+
(15, 'Olivia', 'Operations', 62000, '2021-10-20'),
|
| 55 |
+
(16, 'Paul', 'Customer Service', 46000, '2018-12-12'),
|
| 56 |
+
(17, 'Quinn', 'Sales', 68000, '2020-04-05'),
|
| 57 |
+
(18, 'Rose', 'Engineering', 75000, '2019-03-14'),
|
| 58 |
+
(19, 'Steve', 'Marketing', 56000, '2021-06-30'),
|
| 59 |
+
(20, 'Tracy', 'HR', 49000, '2020-02-02'),
|
| 60 |
+
(21, 'Uma', 'Finance', 54000, '2022-08-08'),
|
| 61 |
+
(22, 'Victor', 'IT', 81000, '2021-09-19'),
|
| 62 |
+
(23, 'Wendy', 'Operations', 78000, '2019-07-27'),
|
| 63 |
+
(24, 'Xander', 'Customer Service', 52000, '2020-11-11'),
|
| 64 |
+
(25, 'Yvonne', 'Sales', 53000, '2021-12-31'),
|
| 65 |
]
|
| 66 |
cursor.executemany('INSERT INTO Employees VALUES (?, ?, ?, ?, ?)', employees_data)
|
| 67 |
|
| 68 |
# Insert sample data into Departments table
|
| 69 |
departments_data = [
|
| 70 |
+
(1, 'Sales', 'Alice'),
|
| 71 |
+
(2, 'Engineering', 'Bob'),
|
| 72 |
+
(3, 'Marketing', 'Charlie'),
|
| 73 |
+
(4, 'HR', 'David'),
|
| 74 |
+
(5, 'Finance', 'Eve'),
|
| 75 |
+
(6, 'IT', 'Frank'),
|
| 76 |
+
(7, 'Operations', 'Grace'),
|
| 77 |
+
(8, 'Customer Service', 'Hank'),
|
| 78 |
]
|
| 79 |
cursor.executemany('INSERT INTO Departments VALUES (?, ?, ?)', departments_data)
|
| 80 |
cursor.execute("INSERT INTO table_metadata (table_name, description) VALUES ('Employees','Details of Employees in Department.')")
|
nlp/__pycache__/query_processor.cpython-312.pyc
CHANGED
|
Binary files a/nlp/__pycache__/query_processor.cpython-312.pyc and b/nlp/__pycache__/query_processor.cpython-312.pyc differ
|
|
|
nlp/__pycache__/sql_model.cpython-312.pyc
CHANGED
|
Binary files a/nlp/__pycache__/sql_model.cpython-312.pyc and b/nlp/__pycache__/sql_model.cpython-312.pyc differ
|
|
|
nlp/sql_model.py
CHANGED
|
@@ -20,6 +20,7 @@ class SQLModel:
|
|
| 20 |
"- ID (INT)\n"
|
| 21 |
"- Name (VARCHAR)\n"
|
| 22 |
"- Manager (VARCHAR)\n\n"
|
|
|
|
| 23 |
"Here are a few examples:\n\n"
|
| 24 |
"1. **Input**: \"Show me all employees in the Sales department.\"\n"
|
| 25 |
"**Output**:\n\n"
|
|
|
|
| 20 |
"- ID (INT)\n"
|
| 21 |
"- Name (VARCHAR)\n"
|
| 22 |
"- Manager (VARCHAR)\n\n"
|
| 23 |
+
|
| 24 |
"Here are a few examples:\n\n"
|
| 25 |
"1. **Input**: \"Show me all employees in the Sales department.\"\n"
|
| 26 |
"**Output**:\n\n"
|