Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import os
|
2 |
import time
|
3 |
import threading
|
@@ -188,15 +189,28 @@ def setup_knowledge_base():
|
|
188 |
all_text += _format_tables_internal(tables) + "\n"
|
189 |
|
190 |
# Process CSVs
|
191 |
-
for filename in ["CustomerOrders.csv"
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
|
201 |
# Tokenization & chunking
|
202 |
tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
|
|
|
1 |
+
This is an app for an online toy store. CustomerOrder.csv contains orders of customer. Application is not fetching customer order and status correctly.
|
2 |
import os
|
3 |
import time
|
4 |
import threading
|
|
|
189 |
all_text += _format_tables_internal(tables) + "\n"
|
190 |
|
191 |
# Process CSVs
|
192 |
+
for filename in ["CustomerOrders.csv"]:
|
193 |
+
csv_path = os.path.join(folder_path, filename)
|
194 |
+
try:
|
195 |
+
with open(csv_path, newline='', encoding='utf-8') as csvfile:
|
196 |
+
reader = csv.DictReader(csvfile) # Use DictReader to get column names
|
197 |
+
for row in reader:
|
198 |
+
line = f"Order ID: {row.get('OrderID')} | Customer Name: {row.get('CustomerName')} | Order Date: {row.get('OrderDate')} | ProductID: {row.get('ProductID')} | Date: {row.get('OrderDate')} | Quantity: {row.get('Quantity')} | UnitPrice(USD): {row.get('UnitPrice(USD)')} | TotalPrice(USD): {row.get('TotalPrice(USD)')} | ShippingAddress: {row.get('ShippingAddress')} | OrderStatus: {row.get('OrderStatus')}"
|
199 |
+
all_text += line + "\n"
|
200 |
+
except Exception as e:
|
201 |
+
print(f"❌ Error reading {filename}: {e}")
|
202 |
+
|
203 |
+
for filename in ["Products.csv"]:
|
204 |
+
csv_path = os.path.join(folder_path, filename)
|
205 |
+
try:
|
206 |
+
with open(csv_path, newline='', encoding='utf-8') as csvfile:
|
207 |
+
reader = csv.DictReader(csvfile) # Use DictReader to get column names
|
208 |
+
for row in reader:
|
209 |
+
line = f"Product ID: {row.get('ProductID')} | Toy Name: {row.get('ToyName')} | Category: {row.get('Category')} | Price(USD): {row.get('Price(USD)')} | Stock Quantity: {row.get('StockQuantity')} | Description: {row.get('Description')}"
|
210 |
+
all_text += line + "\n"
|
211 |
+
except Exception as e:
|
212 |
+
print(f"❌ Error reading {filename}: {e}")
|
213 |
+
|
214 |
|
215 |
# Tokenization & chunking
|
216 |
tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
|