Spaces:
Sleeping
Sleeping
Delete populate_sample_data.py
Browse files- populate_sample_data.py +0 -81
populate_sample_data.py
DELETED
|
@@ -1,81 +0,0 @@
|
|
| 1 |
-
#!/usr/bin/env python3
|
| 2 |
-
"""
|
| 3 |
-
Sample data population script for the LLM Chatbot database.
|
| 4 |
-
This script adds realistic sample transactions to help test the dashboard.
|
| 5 |
-
"""
|
| 6 |
-
|
| 7 |
-
import sys
|
| 8 |
-
import os
|
| 9 |
-
sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
|
| 10 |
-
|
| 11 |
-
from chatbot import Chatbot
|
| 12 |
-
from models import ChatbotRequest
|
| 13 |
-
|
| 14 |
-
def populate_sample_data():
|
| 15 |
-
"""Add sample transactions to the database"""
|
| 16 |
-
|
| 17 |
-
print("π§ Populating database with sample transactions...")
|
| 18 |
-
|
| 19 |
-
# Sample transactions to add
|
| 20 |
-
sample_transactions = [
|
| 21 |
-
# Purchases
|
| 22 |
-
"Add a purchase of 100 wireless mice from TechMart at β¬25 each",
|
| 23 |
-
"Add a purchase of 50 laptop stands from Office Supplies Co at β¬35 each",
|
| 24 |
-
"Add a purchase of 30 webcams from Electronics Plus at β¬80 each",
|
| 25 |
-
"Add a purchase of 75 desk lamps from Office Supplies Co at β¬40 each",
|
| 26 |
-
"Add a purchase of 20 printers from TechMart at β¬200 each",
|
| 27 |
-
"Add a purchase of 60 surge protectors from Electronics Plus at β¬15 each",
|
| 28 |
-
"Add a purchase of 40 ethernet cables from TechMart at β¬12 each",
|
| 29 |
-
"Add a purchase of 15 projectors from Electronics Plus at β¬450 each",
|
| 30 |
-
|
| 31 |
-
# Sales
|
| 32 |
-
"Sold 80 wireless mice to StartupTech Corp at β¬35 each",
|
| 33 |
-
"Sold 30 laptop stands to Creative Agency Ltd at β¬50 each",
|
| 34 |
-
"Sold 25 webcams to Remote Work Solutions at β¬120 each",
|
| 35 |
-
"Sold 50 desk lamps to Modern Office Inc at β¬55 each",
|
| 36 |
-
"Sold 12 printers to Small Business Hub at β¬280 each",
|
| 37 |
-
"Sold 45 surge protectors to Tech Solutions Ltd at β¬25 each",
|
| 38 |
-
"Sold 35 ethernet cables to Network Systems Corp at β¬18 each",
|
| 39 |
-
"Sold 10 projectors to Conference Center Co at β¬650 each",
|
| 40 |
-
"Sold 5 laptops to Freelance Collective at β¬1400 each",
|
| 41 |
-
"Sold 25 monitors to Design Studio Ltd at β¬380 each",
|
| 42 |
-
]
|
| 43 |
-
|
| 44 |
-
chatbot = Chatbot()
|
| 45 |
-
|
| 46 |
-
try:
|
| 47 |
-
successful_transactions = 0
|
| 48 |
-
failed_transactions = 0
|
| 49 |
-
|
| 50 |
-
for transaction in sample_transactions:
|
| 51 |
-
try:
|
| 52 |
-
print(f"π Processing: {transaction}")
|
| 53 |
-
request = ChatbotRequest(message=transaction)
|
| 54 |
-
response = chatbot.process_message(request)
|
| 55 |
-
|
| 56 |
-
if "recorded" in response.response.lower():
|
| 57 |
-
successful_transactions += 1
|
| 58 |
-
print(f"β
Success: {response.response}")
|
| 59 |
-
else:
|
| 60 |
-
failed_transactions += 1
|
| 61 |
-
print(f"β οΈ Warning: {response.response}")
|
| 62 |
-
|
| 63 |
-
except Exception as e:
|
| 64 |
-
failed_transactions += 1
|
| 65 |
-
print(f"β Error processing transaction: {e}")
|
| 66 |
-
|
| 67 |
-
print(f"\nπ Summary:")
|
| 68 |
-
print(f"β
Successful transactions: {successful_transactions}")
|
| 69 |
-
print(f"β Failed transactions: {failed_transactions}")
|
| 70 |
-
print(f"π― Total attempted: {len(sample_transactions)}")
|
| 71 |
-
|
| 72 |
-
if successful_transactions > 0:
|
| 73 |
-
print(f"\nπ Database populated with {successful_transactions} sample transactions!")
|
| 74 |
-
print("π‘ You can now run the dashboard to see meaningful data.")
|
| 75 |
-
print("π Run 'python run_gui.py' to launch the Gradio interface.")
|
| 76 |
-
|
| 77 |
-
finally:
|
| 78 |
-
chatbot.close()
|
| 79 |
-
|
| 80 |
-
if __name__ == "__main__":
|
| 81 |
-
populate_sample_data()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|