tsrivallabh commited on
Commit
a38e4b0
·
verified ·
1 Parent(s): 8611725

Upload 37 files

Browse files
Files changed (38) hide show
  1. .gitattributes +17 -0
  2. assets/all_resto.png +3 -0
  3. assets/booking_successful.png +3 -0
  4. assets/general_conv_info_through_chat.png +3 -0
  5. assets/greet_general_convo.png +3 -0
  6. assets/landing.png +3 -0
  7. assets/mermaid-1.png +3 -0
  8. assets/mermaid.png +3 -0
  9. assets/name_entering.png +3 -0
  10. assets/ready_to_book.png +3 -0
  11. assets/rubbish.PNG +3 -0
  12. assets/some_results.PNG +3 -0
  13. db/chroma/0f1c557e-a6e2-45cb-8079-0720b4f2093f/data_level0.bin +3 -0
  14. db/chroma/0f1c557e-a6e2-45cb-8079-0720b4f2093f/header.bin +0 -0
  15. db/chroma/0f1c557e-a6e2-45cb-8079-0720b4f2093f/length.bin +0 -0
  16. db/chroma/0f1c557e-a6e2-45cb-8079-0720b4f2093f/link_lists.bin +0 -0
  17. db/chroma/45948c9b-58d5-4762-9fd1-cf9b5925ba84/data_level0.bin +3 -0
  18. db/chroma/45948c9b-58d5-4762-9fd1-cf9b5925ba84/header.bin +0 -0
  19. db/chroma/45948c9b-58d5-4762-9fd1-cf9b5925ba84/length.bin +0 -0
  20. db/chroma/45948c9b-58d5-4762-9fd1-cf9b5925ba84/link_lists.bin +0 -0
  21. db/chroma/b97e1f95-8691-4375-b2f8-2f2e96d82a8c/data_level0.bin +3 -0
  22. db/chroma/b97e1f95-8691-4375-b2f8-2f2e96d82a8c/header.bin +0 -0
  23. db/chroma/b97e1f95-8691-4375-b2f8-2f2e96d82a8c/index_metadata.pickle +3 -0
  24. db/chroma/b97e1f95-8691-4375-b2f8-2f2e96d82a8c/length.bin +0 -0
  25. db/chroma/b97e1f95-8691-4375-b2f8-2f2e96d82a8c/link_lists.bin +0 -0
  26. db/chroma/chroma.sqlite3 +3 -0
  27. db/create_base.py +64 -0
  28. db/create_slots.py +33 -0
  29. db/dbmodify.py +54 -0
  30. db/fill_details.py +141 -0
  31. db/print_db.py +24 -0
  32. db/resetdb.py +27 -0
  33. db/restaurant_reservation.db +3 -0
  34. prompts/determine_intent.txt +21 -0
  35. prompts/generate_reservation_conversation.txt +30 -0
  36. prompts/interpret_sql_result.txt +28 -0
  37. prompts/schema_prompt.txt +50 -0
  38. prompts/store_user_info.txt +35 -0
.gitattributes CHANGED
@@ -1,2 +1,19 @@
1
  # Auto detect text files and perform LF normalization
2
  * text=auto
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # Auto detect text files and perform LF normalization
2
  * text=auto
3
+ assets/all_resto.png filter=lfs diff=lfs merge=lfs -text
4
+ assets/booking_successful.png filter=lfs diff=lfs merge=lfs -text
5
+ assets/general_conv_info_through_chat.png filter=lfs diff=lfs merge=lfs -text
6
+ assets/greet_general_convo.png filter=lfs diff=lfs merge=lfs -text
7
+ assets/landing.png filter=lfs diff=lfs merge=lfs -text
8
+ assets/mermaid-1.png filter=lfs diff=lfs merge=lfs -text
9
+ assets/mermaid.png filter=lfs diff=lfs merge=lfs -text
10
+ assets/name_entering.png filter=lfs diff=lfs merge=lfs -text
11
+ assets/ready_to_book.png filter=lfs diff=lfs merge=lfs -text
12
+ assets/rubbish.PNG filter=lfs diff=lfs merge=lfs -text
13
+ assets/some_results.PNG filter=lfs diff=lfs merge=lfs -text
14
+ db/chroma/0f1c557e-a6e2-45cb-8079-0720b4f2093f/data_level0.bin filter=lfs diff=lfs merge=lfs -text
15
+ db/chroma/45948c9b-58d5-4762-9fd1-cf9b5925ba84/data_level0.bin filter=lfs diff=lfs merge=lfs -text
16
+ db/chroma/b97e1f95-8691-4375-b2f8-2f2e96d82a8c/data_level0.bin filter=lfs diff=lfs merge=lfs -text
17
+ db/chroma/b97e1f95-8691-4375-b2f8-2f2e96d82a8c/index_metadata.pickle filter=lfs diff=lfs merge=lfs -text
18
+ db/chroma/chroma.sqlite3 filter=lfs diff=lfs merge=lfs -text
19
+ db/restaurant_reservation.db filter=lfs diff=lfs merge=lfs -text
assets/all_resto.png ADDED

Git LFS Details

  • SHA256: 75439b4abe2272f6022a16cc3705287f423d5907409dca18c4bb329edd9fcf68
  • Pointer size: 131 Bytes
  • Size of remote file: 177 kB
assets/booking_successful.png ADDED

Git LFS Details

  • SHA256: 405e43a9a4a6bdb24e0ad26bcd56a26e39ec022669bc5e87f0147d6dc6cbe12a
  • Pointer size: 131 Bytes
  • Size of remote file: 135 kB
assets/general_conv_info_through_chat.png ADDED

Git LFS Details

  • SHA256: 937cf76cd735fe0f39ab08b8e66cbb91ab522367e33520c4cae911516916da16
  • Pointer size: 131 Bytes
  • Size of remote file: 152 kB
assets/greet_general_convo.png ADDED

Git LFS Details

  • SHA256: e16d00f649f0d8e4ff797e50cb6422dba3802e3eb63d9c3a5144edaf185a0da3
  • Pointer size: 131 Bytes
  • Size of remote file: 122 kB
assets/landing.png ADDED

Git LFS Details

  • SHA256: fd03aaefe954c0527859cab2c8a74d2d5ea1c9dc18d4a502028807b08989bdf7
  • Pointer size: 131 Bytes
  • Size of remote file: 103 kB
assets/mermaid-1.png ADDED

Git LFS Details

  • SHA256: 372b67dd2b410f2537ab071bbe05b82c77ddb830ccffe54762276e358735a51a
  • Pointer size: 131 Bytes
  • Size of remote file: 600 kB
assets/mermaid.png ADDED

Git LFS Details

  • SHA256: d000eb1764401330a7cf99cfde781faf06f19cbab424bd39e83984576fee466e
  • Pointer size: 131 Bytes
  • Size of remote file: 562 kB
assets/name_entering.png ADDED

Git LFS Details

  • SHA256: 78a06bd163dd9269f0ad572ced2ed6fb31a354b9e3d4920e08885fbb0ec65553
  • Pointer size: 131 Bytes
  • Size of remote file: 124 kB
assets/ready_to_book.png ADDED

Git LFS Details

  • SHA256: 5c805bdcebf89e178565f037a24b97367743985bce7bb93e86e33dd0e99e215b
  • Pointer size: 131 Bytes
  • Size of remote file: 137 kB
assets/rubbish.PNG ADDED

Git LFS Details

  • SHA256: 846c39c6265b506e8e20788333cd8bf0b7e73d52b86139cce92a58588cc31c75
  • Pointer size: 131 Bytes
  • Size of remote file: 102 kB
assets/some_results.PNG ADDED

Git LFS Details

  • SHA256: 2bfb3f7631528ff646eaeeba9cce0b56b612930575b145c3c34167a979a3f4f6
  • Pointer size: 131 Bytes
  • Size of remote file: 146 kB
db/chroma/0f1c557e-a6e2-45cb-8079-0720b4f2093f/data_level0.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8146ecc3e4c3a36ea9b3edc3778630c452f483990ec942d38e8006f4661e430
3
+ size 16760000
db/chroma/0f1c557e-a6e2-45cb-8079-0720b4f2093f/header.bin ADDED
Binary file (100 Bytes). View file
 
db/chroma/0f1c557e-a6e2-45cb-8079-0720b4f2093f/length.bin ADDED
Binary file (40 kB). View file
 
db/chroma/0f1c557e-a6e2-45cb-8079-0720b4f2093f/link_lists.bin ADDED
File without changes
db/chroma/45948c9b-58d5-4762-9fd1-cf9b5925ba84/data_level0.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8146ecc3e4c3a36ea9b3edc3778630c452f483990ec942d38e8006f4661e430
3
+ size 16760000
db/chroma/45948c9b-58d5-4762-9fd1-cf9b5925ba84/header.bin ADDED
Binary file (100 Bytes). View file
 
db/chroma/45948c9b-58d5-4762-9fd1-cf9b5925ba84/length.bin ADDED
Binary file (40 kB). View file
 
db/chroma/45948c9b-58d5-4762-9fd1-cf9b5925ba84/link_lists.bin ADDED
File without changes
db/chroma/b97e1f95-8691-4375-b2f8-2f2e96d82a8c/data_level0.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3cdd813c7b938a646786a77ee5e41520302ea0d68cda1b40a41e3e633c7165a8
3
+ size 16760000
db/chroma/b97e1f95-8691-4375-b2f8-2f2e96d82a8c/header.bin ADDED
Binary file (100 Bytes). View file
 
db/chroma/b97e1f95-8691-4375-b2f8-2f2e96d82a8c/index_metadata.pickle ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18ec9cba57199ceca85f8017e5eec2047d0538fbeb5024abc3c260ba5ecbedb8
3
+ size 312140
db/chroma/b97e1f95-8691-4375-b2f8-2f2e96d82a8c/length.bin ADDED
Binary file (40 kB). View file
 
db/chroma/b97e1f95-8691-4375-b2f8-2f2e96d82a8c/link_lists.bin ADDED
Binary file (25.4 kB). View file
 
db/chroma/chroma.sqlite3 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e4155d5fe23b85c0794c1e7f4e4dd065d3ec1193320dd312f77a3ae1c48eae3b
3
+ size 5046272
db/create_base.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sqlite3
2
+
3
+ # Connect to the SQLite database
4
+ conn = sqlite3.connect("restaurant_reservation.db")
5
+ cursor = conn.cursor()
6
+
7
+ # Create tables if they do not exist
8
+ cursor.executescript("""
9
+ CREATE TABLE IF NOT EXISTS restaurants (
10
+ id TEXT PRIMARY KEY,
11
+ name TEXT NOT NULL,
12
+ cuisine TEXT,
13
+ location TEXT,
14
+ seating_capacity INTEGER,
15
+ rating REAL,
16
+ address TEXT,
17
+ contact TEXT,
18
+ price_range TEXT,
19
+ special_features TEXT
20
+ );
21
+
22
+ CREATE TABLE IF NOT EXISTS tables (
23
+ id TEXT PRIMARY KEY,
24
+ restaurant_id TEXT,
25
+ capacity INTEGER DEFAULT 4,
26
+ FOREIGN KEY (restaurant_id) REFERENCES restaurants(id)
27
+ );
28
+
29
+ CREATE TABLE IF NOT EXISTS slots (
30
+ id TEXT PRIMARY KEY,
31
+ table_id TEXT,
32
+ date TEXT,
33
+ hour INTEGER,
34
+ is_reserved INTEGER DEFAULT 0,
35
+ FOREIGN KEY (table_id) REFERENCES tables(id)
36
+ );
37
+
38
+ CREATE TABLE IF NOT EXISTS reservations (
39
+ id TEXT PRIMARY KEY,
40
+ restaurant_id TEXT,
41
+ user_name TEXT,
42
+ contact TEXT,
43
+ date TEXT,
44
+ time INTEGER,
45
+ party_size INTEGER,
46
+ FOREIGN KEY (restaurant_id) REFERENCES restaurants(id)
47
+ );
48
+
49
+ CREATE TABLE IF NOT EXISTS reservation_tables (
50
+ id TEXT PRIMARY KEY,
51
+ reservation_id TEXT,
52
+ table_id TEXT,
53
+ FOREIGN KEY (reservation_id) REFERENCES reservations(id),
54
+ FOREIGN KEY (table_id) REFERENCES tables(id)
55
+ );
56
+ """)
57
+
58
+ # Commit the changes
59
+ conn.commit()
60
+
61
+ # Close the connection
62
+ conn.close()
63
+
64
+ print("Tables have been created successfully!")
db/create_slots.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sqlite3
2
+ import uuid
3
+ from datetime import datetime
4
+
5
+ # Connect to your SQLite DB
6
+ conn = sqlite3.connect("restaurant_reservation.db")
7
+ cursor = conn.cursor()
8
+
9
+ # Get all table IDs
10
+ cursor.execute("SELECT id FROM tables")
11
+ table_ids = [row[0] for row in cursor.fetchall()]
12
+
13
+ # Define the time range and current date
14
+ start_hour = 9 # 9AM
15
+ end_hour = 21 # 9PM
16
+
17
+ # Prepare slot entries
18
+ slot_entries = []
19
+ for table_id in table_ids:
20
+ for hour in range(start_hour, end_hour):
21
+ slot_id = str(uuid.uuid4())
22
+ slot_entries.append((slot_id, table_id, "2025-05-12", hour, 0)) # is_reserved = 0
23
+
24
+ # Insert into slots table
25
+ cursor.executemany("""
26
+ INSERT INTO slots (id, table_id, date, hour, is_reserved)
27
+ VALUES (?, ?, ?, ?, ?)
28
+ """, slot_entries)
29
+
30
+ conn.commit()
31
+ conn.close()
32
+
33
+ print("✅ Slots successfully added for all tables for today.")
db/dbmodify.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import sqlite3
2
+
3
+ # conn = sqlite3.connect("restaurant_reservation.db")
4
+ # cursor = conn.cursor()
5
+
6
+ # # Drop the existing empty tables
7
+ # cursor.execute("DROP TABLE IF EXISTS reservations;")
8
+ # cursor.execute("DROP TABLE IF EXISTS reservation_tables;")
9
+
10
+ # # Recreate the tables with AUTOINCREMENT for `id`
11
+ # cursor.execute("""
12
+ # CREATE TABLE reservations (
13
+ # id INTEGER PRIMARY KEY AUTOINCREMENT,
14
+ # restaurant_id TEXT,
15
+ # user_name TEXT,
16
+ # contact TEXT,
17
+ # date TEXT, -- Hard coded to 2025-05-12
18
+ # time TEXT,
19
+ # party_size INTEGER
20
+ # );
21
+ # """)
22
+
23
+ # cursor.execute("""
24
+ # CREATE TABLE reservation_tables (
25
+ # id INTEGER PRIMARY KEY AUTOINCREMENT,
26
+ # reservation_id TEXT,
27
+ # table_id TEXT
28
+ # );
29
+ # """)
30
+
31
+ # conn.commit()
32
+ # conn.close()
33
+
34
+ # print("Tables recreated successfully with AUTOINCREMENT ids.")
35
+
36
+ import sqlite3
37
+
38
+ conn = sqlite3.connect("restaurant_reservation.db")
39
+ cursor = conn.cursor()
40
+
41
+ try:
42
+ cursor.execute("""
43
+ UPDATE restaurants
44
+ SET name = 'Street Tacos Co'
45
+ WHERE name = 'Street Tacos Co.';
46
+ """)
47
+ conn.commit()
48
+ print("✅ Restaurant name updated successfully.")
49
+ except Exception as e:
50
+ conn.rollback()
51
+ print(f"❌ Update failed: {e}")
52
+ finally:
53
+ conn.close()
54
+
db/fill_details.py ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import uuid
2
+ import random
3
+ import sqlite3
4
+
5
+ # ---------------------------
6
+ # Data Classes
7
+ # ---------------------------
8
+ class Restaurant:
9
+ def __init__(self, restaurant_id, name, cuisine, location, seating_capacity, rating, address, contact, price_range, special_features):
10
+ self.restaurant_id = restaurant_id
11
+ self.name = name
12
+ self.cuisine = cuisine
13
+ self.location = location
14
+ self.seating_capacity = seating_capacity
15
+ self.rating = rating
16
+ self.address = address
17
+ self.contact = contact
18
+ self.price_range = price_range
19
+ self.special_features = special_features
20
+ self.tables = []
21
+
22
+ class Table:
23
+ def __init__(self, table_id, restaurant_id, capacity=4):
24
+ self.table_id = table_id
25
+ self.restaurant_id = restaurant_id
26
+ self.capacity = capacity
27
+
28
+ # ---------------------------
29
+ # Sample Data
30
+ # ---------------------------
31
+ restaurant_names = [
32
+ "Bella Italia", "Spice Symphony", "Tokyo Ramen House", "Saffron Grill", "El Toro Loco",
33
+ "Noodle Bar", "Le Petit Bistro", "Tandoori Nights", "Green Leaf Cafe", "Ocean Pearl",
34
+ "Mama Mia Pizza", "The Dumpling Den", "Bangkok Express", "Curry Kingdom", "The Garden Table",
35
+ "Skyline Dine", "Pasta Republic", "Street Tacos Co", "Miso Hungry", "Chez Marie"
36
+ ]
37
+
38
+ locations = ['Downtown', 'Uptown', 'Midtown', 'Suburbs']
39
+ special_features_list = ['Outdoor Seating', 'Pet-Friendly', 'Live Music', 'Rooftop View', 'Private Dining']
40
+
41
+ def infer_cuisine(name):
42
+ name = name.lower()
43
+ if "italia" in name or "pasta" in name or "mama mia" in name:
44
+ return "Italian"
45
+ elif "tokyo" in name or "ramen" in name or "miso" in name:
46
+ return "Japanese"
47
+ elif "saffron" in name or "tandoori" in name or "curry" in name:
48
+ return "Indian"
49
+ elif "dumpling" in name or "noodle" in name:
50
+ return "Chinese"
51
+ elif "bistro" in name or "chez" in name or "marie" in name:
52
+ return "French"
53
+ elif "bangkok" in name:
54
+ return "Thai"
55
+ elif "el toro" in name or "tacos" in name:
56
+ return "Mexican"
57
+ elif "green" in name or "garden" in name:
58
+ return random.choice(["Multi-Cuisine", "Healthy", "Fusion"])
59
+ elif "skyline" in name or "ocean" in name:
60
+ return random.choice(["Multi-Cuisine", "Seafood", "Fusion"])
61
+ else:
62
+ return random.choice(["Italian", "Mexican", "Indian", "Japanese", "Chinese", "Thai", "French", "Multi-Cuisine"])
63
+
64
+ # Create restaurant objects
65
+ restaurants = []
66
+
67
+ for i in range(20):
68
+ rest_id = str(uuid.uuid4())
69
+ name = restaurant_names[i]
70
+ cuisine = infer_cuisine(name)
71
+ if cuisine == "Multi-Cuisine":
72
+ cuisine = random.sample(["Italian", "Chinese", "Indian", "Mexican", "French"], k=2)
73
+
74
+ location = random.choice(locations)
75
+ num_tables = random.randint(10, 20)
76
+ seating_capacity = num_tables * 4
77
+ rating = round(random.uniform(3.5, 5.0), 1)
78
+ address = f"{100 + i} Main Street, {location}"
79
+ contact = f"555-{1000 + i}"
80
+ price_range = random.choice(['$', '$$', '$$$'])
81
+ features = random.sample(special_features_list, k=2)
82
+
83
+ restaurant = Restaurant(
84
+ restaurant_id=rest_id,
85
+ name=name,
86
+ cuisine=cuisine,
87
+ location=location,
88
+ seating_capacity=seating_capacity,
89
+ rating=rating,
90
+ address=address,
91
+ contact=contact,
92
+ price_range=price_range,
93
+ special_features=features
94
+ )
95
+
96
+ for _ in range(num_tables):
97
+ table_id = str(uuid.uuid4())
98
+ table = Table(table_id=table_id, restaurant_id=rest_id)
99
+ restaurant.tables.append(table)
100
+
101
+ restaurants.append(restaurant)
102
+
103
+ # ---------------------------
104
+ # Insert into SQLite Database
105
+ # ---------------------------
106
+ conn = sqlite3.connect("restaurant_reservation.db")
107
+ cursor = conn.cursor()
108
+
109
+ for r in restaurants:
110
+ cuisine_str = ", ".join(r.cuisine) if isinstance(r.cuisine, list) else r.cuisine
111
+ features_str = ", ".join(r.special_features)
112
+
113
+ cursor.execute("""
114
+ INSERT INTO restaurants (id, name, cuisine, location, seating_capacity, rating, address, contact, price_range, special_features)
115
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
116
+ """, (
117
+ r.restaurant_id,
118
+ r.name,
119
+ cuisine_str,
120
+ r.location,
121
+ r.seating_capacity,
122
+ r.rating,
123
+ r.address,
124
+ r.contact,
125
+ r.price_range,
126
+ features_str
127
+ ))
128
+
129
+ for t in r.tables:
130
+ cursor.execute("""
131
+ INSERT INTO tables (id, restaurant_id, capacity)
132
+ VALUES (?, ?, ?)
133
+ """, (
134
+ t.table_id,
135
+ t.restaurant_id,
136
+ t.capacity
137
+ ))
138
+
139
+ conn.commit()
140
+ conn.close()
141
+ print("✅ Restaurants and tables successfully added to the database.")
db/print_db.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sqlite3
2
+
3
+ # Connect to the SQLite database
4
+ conn = sqlite3.connect("restaurant_reservation.db")
5
+ cursor = conn.cursor()
6
+
7
+ # Function to print table contents
8
+ def print_table_contents(table_name):
9
+ print(f"Contents of the {table_name} table:")
10
+ cursor.execute(f"SELECT * FROM {table_name}")
11
+ rows = cursor.fetchall()
12
+ for row in rows:
13
+ print(row)
14
+ print("\n")
15
+
16
+ # Print contents of all the tables
17
+ print_table_contents("restaurants")
18
+ print_table_contents("tables")
19
+ print_table_contents("slots")
20
+ print_table_contents("reservations")
21
+ print_table_contents("reservation_tables")
22
+
23
+ # Close the database connection
24
+ conn.close()
db/resetdb.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sqlite3
2
+
3
+ def reset_reservations():
4
+ sql_statements = [
5
+ "UPDATE slots SET is_reserved = 0;",
6
+ "DELETE FROM reservation_tables;",
7
+ "DELETE FROM reservations;"
8
+ ]
9
+
10
+ try:
11
+ conn = sqlite3.connect("restaurant_reservation.db")
12
+ cursor = conn.cursor()
13
+
14
+ cursor.execute("BEGIN TRANSACTION;")
15
+ for stmt in sql_statements:
16
+ cursor.execute(stmt)
17
+ conn.commit()
18
+ conn.close()
19
+ return "✅ All slots marked as reserved and reservations cleared."
20
+ except Exception as e:
21
+ conn.rollback()
22
+ conn.close()
23
+ return f"❌ Error during reset: {e}"
24
+
25
+ # Call this function
26
+ result = reset_reservations()
27
+ print(result)
db/restaurant_reservation.db ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7663a4d218aae1e7d53ef8594b6d366506fe95a96f00f7a10e9e95df0416d883
3
+ size 1273856
prompts/determine_intent.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are an intent classification assistant for a restaurant reservation system.
2
+
3
+ User input: "{user_input}"
4
+
5
+ Classify the intent as one of:
6
+ - STORE: User shares name, contact, or reservation details (like party size or time) without asking anything.
7
+ - SELECT: User asks about availability, restaurants, time slots, or capacity.
8
+ - BOOK: User says only "book" (case-insensitive). Even "I want to book..." is SELECT, not BOOK.
9
+ - GREET: User greets or starts a conversation without giving info or asking.
10
+ - RUBBISH: Input is gibberish, irrelevant, or unrecognizable.
11
+
12
+ Examples:
13
+ - "My name is Raj" → STORE
14
+ - "book" → BOOK
15
+ - "15 people" → SELECT
16
+ - "Tell me best restaurants" → SELECT
17
+ - "7801061333" → STORE
18
+ - "asdfgh" → RUBBISH
19
+ - "Hi there" → GREET
20
+
21
+ Respond with ONE word only: SELECT, STORE, BOOK, GREET, or RUBBISH. No explanation
prompts/generate_reservation_conversation.txt ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are a professional restaurant reservation assistant helping a customer make a booking. Speak concisely and professionally. Unless the booking is complete, end with a helpful question.
2
+
3
+ User said: "{user_query}"
4
+ Always try to answer this user query.
5
+ Current known user data (JSON): {user_data}
6
+ Only ask about missing fields (those with null/None values). Do not repeat questions for data already present.
7
+ Never ask about the fields that are already present in the user data json.
8
+ - user_name: user's name
9
+ - contact: user’s phone (not for queries)
10
+ - restaurant_name: name of restaurant
11
+ - party_size: number of people
12
+ - time: hour of reservation (9–20)
13
+
14
+ If restaurant_name is missing, offer to suggest restaurants or cuisines. Never mention "null"—be conversational. Show known info naturally if helpful.
15
+
16
+ Database info:
17
+ "{sql_summary}"
18
+ Explain this clearly based on what user said. If it says:
19
+ - "Info Stored": thank the user and ask next missing info.
20
+ - "✅ Booking processed successfully.": Tell thanks for booking, I could assist you in new booking, also I could tell about restaurant features, pricing, etc, dont ask anything else.
21
+ - "❌ Booking failed: ...": explain the error simply and suggest trying again.
22
+ - A greeting: respond politely and ask if they need help with restaurant info or making a booking.
23
+
24
+ Personalize your response using available user data. Each table seats 4 people; use ceil(party_size / 4) to estimate how many are needed.
25
+ Try to explain as much information as possible from database info in a concise, professional way.
26
+
27
+ History snippet: "{history_prompt_snippet}"
28
+ If earlier prompts asked for something now present in user data, don't ask again.
29
+
30
+ Be helpful, efficient, and professional in tone.
prompts/interpret_sql_result.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are an expert assistant interpreting SQL query results for a restaurant reservation system.
2
+ Try to explain as much information as possible from database info in a concise, professional way.
3
+ Database schema overview:
4
+ - restaurants(id, name, cuisine, location, seating_capacity, rating, address, contact, price_range [$, $$, $$$], special_features)
5
+ - tables(id, restaurant_id, capacity=4)
6
+ - slots(id, table_id, date, hour [9-21], is_reserved [0=free,1=reserved])
7
+
8
+ Notes:
9
+ - Each table seats 4 guests.
10
+ - To accommodate a party, number_of_tables_needed = ceil(party_size / 4).
11
+ - Slots represent table availability by hour.
12
+ - The queries return counts or details based on user questions.
13
+
14
+ You will get:
15
+ - User question: {user_query}
16
+ - Executed SQL query: {sql_query}
17
+ Understand this sql clearly and properly.
18
+ - Query result as JSON: {result_str}
19
+
20
+ Instructions:
21
+ - Provide a clear, professional summary of the query result in context of the user's question and the sql query.
22
+ - For availability queries, explain if enough tables are free for the requested party size and time.
23
+ - For list queries, list relevant restaurant details clearly.
24
+ - If no data is found, say so politely.
25
+ - Do not ask follow-up questions or add info not supported by the data.
26
+
27
+
28
+ Now summarize the result based on the user query and data.
prompts/schema_prompt.txt ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are an expert AI assistant for a restaurant reservation system using SQLite.
2
+ Your goal is to generate a single SELECT SQL query only.
3
+
4
+ Use COUNT for availability checks to reduce result size, but when the query asks for restaurant info (name, rating, pricing, features), use regular SELECT without COUNT.
5
+
6
+ SCHEMA
7
+ - restaurants(id, name, cuisine, location, seating_capacity, rating, address, contact, price_range, special_features)
8
+ - tables(id, restaurant_id, capacity = 4)
9
+ - slots(id, table_id, date, hour, is_reserved = 0)
10
+ strictly follow this schema
11
+
12
+ LOGIC
13
+ - Each table seats 4 → use CEIL(party_size / 4) to get number of tables needed.
14
+ - Only consider slots where is_reserved = 0 and the date = '2025-05-12'.
15
+ - JOIN order: slots → tables → restaurants
16
+ - Use explicit column aliases to avoid ambiguity (e.g., s.id AS slot_id).
17
+ - Never reference internal id fields in user-facing outputs.
18
+ - Avoid SELECT * in multi-table joins.
19
+
20
+ EXAMPLES
21
+ 1. Availability:
22
+ SELECT COUNT(*) AS availability FROM slots WHERE is_reserved = 0 AND table_id IN (SELECT id FROM tables WHERE restaurant_id = (SELECT id FROM restaurants WHERE LOWER(name) = 'bella italia'));
23
+
24
+ 2. Availability at time:
25
+ SELECT COUNT(*) AS available_tables FROM slots WHERE hour = 10 AND is_reserved = 0 AND table_id IN (SELECT id FROM tables WHERE restaurant_id = (SELECT id FROM restaurants WHERE LOWER(name) = 'bella italia'));
26
+
27
+ 3. Availability for party size:
28
+ SELECT COUNT(*) AS available_tables FROM slots WHERE hour = 12 AND is_reserved = 0 AND table_id IN (SELECT id FROM tables WHERE restaurant_id = (SELECT id FROM restaurants WHERE LOWER(name) = 'bella italia'));
29
+ → compare count to CEIL(6 / 4) externally.
30
+
31
+ 4. Restaurant info:
32
+ SELECT price_range FROM restaurants WHERE LOWER(name) = 'bella italia';
33
+ 5. Best restaurants:
34
+ SELECT * FROM restaurants ORDER BY rating DESC
35
+ 5. Best restaurant with Mexican cuisine:
36
+ SELECT * FROM restaurants WHERE cuisine LIKE '%Mexican%' ORDER BY rating DESC LIMIT 1;
37
+ 6. Which cuisine has the best rating? :
38
+ SELECT cuisine, name AS restaurant_name, rating
39
+ FROM restaurants
40
+ ORDER BY rating DESC
41
+ LIMIT 1;
42
+ 7. Total list:
43
+ "Give me a list of restaurants"
44
+ SELECT FROM restaurants
45
+ PRICING TERMS
46
+ - "cheap" → $
47
+ - "moderate" → $$
48
+ - "expensive" → $$$
49
+
50
+ History: {history_prompt}\n\nUser: {user_input}\nGive only SQL query as answer, SQL:
prompts/store_user_info.txt ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ You are a helpful assistant. Extract relevant user information from this user statement:
2
+ "{user_input}"
3
+
4
+ Previously collected data in json: {previous_info}
5
+ Always remember this json data, you need to update this based on user statement.
6
+ if user statement is book, dont change any value in this data
7
+ Return a JSON object with the following possible keys:
8
+ - restaurant_name - text
9
+ - user_name - text
10
+ - contact - text
11
+ - party_size - integer
12
+ - time (between 9 to 20, 9 represents 9AM, 20 represents 8PM) - integer
13
+ Donot consider time which is before 9 or after 20.
14
+ Never modify any entry to null if previous data is not null for that field.
15
+ Update the previous data with any new fields found. Do not make previously known fields unless you are sure the user wants to change them.
16
+ Respond ONLY with a single valid JSON object.
17
+ important rules:
18
+ - "restaurant_name": Must always match from this list:
19
+ Bella Italia, Spice Symphony, Tokyo Ramen House, Saffron Grill, El Toro Loco, Noodle Bar, Le Petit Bistro, Tandoori Nights, Green Leaf Cafe, Ocean Pearl, Mama Mia Pizza, The Dumpling Den, Bangkok Express, Curry Kingdom, The Garden Table, Skyline Dine, Pasta Republic, Street Tacos Co, Miso Hungry, Chez Marie
20
+
21
+
22
+ If in previously collected data, the restaurant_name is there but not in this list as the exact spelling or not with correct casing, replace it with the correct one.
23
+
24
+ If user statement is a restaurant_name, dont modify user_name thinking that it is restaurant name, only modify user_name.
25
+ - "user_name":
26
+ - Only extract if the input clearly states a name like “My name is ...” or “This is ...”
27
+ - Do not extract from greetings like “Hi”, “Hello”, “Hey”, “Yo”, “Good evening”
28
+ - Do not invent names based on formatting or assumptions
29
+
30
+ Output format rules:
31
+ -Make sure restaurant_name matches from the list given
32
+ - Return only valid JSON — starting with {{ and ending with }}
33
+ - All keys and values must be in double quotes
34
+ - Include all 5 keys in the output
35
+ - No markdown, comments, or explanation in output, just give a json