Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -192,18 +192,19 @@ def setup_knowledge_base():
|
|
192 |
csv_path = os.path.join(folder_path, filename)
|
193 |
try:
|
194 |
with open(csv_path, newline='', encoding='utf-8') as csvfile:
|
195 |
-
reader = csv.DictReader(csvfile)
|
196 |
for row in reader:
|
197 |
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')}"
|
198 |
all_text += line + "\n"
|
199 |
except Exception as e:
|
200 |
print(f"❌ Error reading {filename}: {e}")
|
|
|
201 |
|
202 |
for filename in ["Products.csv"]:
|
203 |
csv_path = os.path.join(folder_path, filename)
|
204 |
try:
|
205 |
with open(csv_path, newline='', encoding='utf-8') as csvfile:
|
206 |
-
reader = csv.DictReader(csvfile)
|
207 |
for row in reader:
|
208 |
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')}"
|
209 |
all_text += line + "\n"
|
@@ -211,6 +212,7 @@ def setup_knowledge_base():
|
|
211 |
print(f"❌ Error reading {filename}: {e}")
|
212 |
|
213 |
|
|
|
214 |
# Tokenization & chunking
|
215 |
tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
|
216 |
chunks = chunk_text(all_text, tokenizer)
|
|
|
192 |
csv_path = os.path.join(folder_path, filename)
|
193 |
try:
|
194 |
with open(csv_path, newline='', encoding='utf-8') as csvfile:
|
195 |
+
reader = csv.DictReader(csvfile)
|
196 |
for row in reader:
|
197 |
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')}"
|
198 |
all_text += line + "\n"
|
199 |
except Exception as e:
|
200 |
print(f"❌ Error reading {filename}: {e}")
|
201 |
+
|
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)
|
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"
|
|
|
212 |
print(f"❌ Error reading {filename}: {e}")
|
213 |
|
214 |
|
215 |
+
|
216 |
# Tokenization & chunking
|
217 |
tokenizer = AutoTokenizer.from_pretrained('bert-base-uncased')
|
218 |
chunks = chunk_text(all_text, tokenizer)
|