Business_Chatbot / main.py
Ancastal's picture
Upload folder using huggingface_hub
401b16c verified
#!/usr/bin/env python3
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__), 'src'))
from chatbot import Chatbot
from models import ChatbotRequest
def main():
print("πŸ€– Business Chatbot with SQL Database and Vector Store")
print("="*60)
print("I can help you with:")
print("β€’ Adding purchases: 'Add a purchase of 20 USB drives from TechMart at €5 each'")
print("β€’ Adding sales: 'Sold 10 laptops to John Smith at €800 each'")
print("β€’ Viewing recent transactions: 'Show recent transactions'")
print("β€’ Searching: 'Find USB drives' or 'Search TechMart'")
print("β€’ Storing general info: 'Meeting with supplier scheduled for next week'")
print("β€’ Type 'quit' to exit")
print("="*60)
chatbot = Chatbot()
try:
while True:
user_input = input("\nπŸ’¬ You: ").strip()
if user_input.lower() in ['quit', 'exit', 'bye']:
print("πŸ‘‹ Goodbye!")
break
if not user_input:
continue
# Process the message
request = ChatbotRequest(message=user_input)
response = chatbot.process_message(request)
print(f"\nπŸ€– Bot: {response.response}")
# Show additional info if available
if response.entities_extracted:
print(f"πŸ“Š Extracted: {response.entities_extracted.transaction_type} - {response.entities_extracted.product} ({response.entities_extracted.quantity}x) - €{response.entities_extracted.total_amount}")
if response.vector_stored:
print("πŸ’Ύ Information stored in vector database for future semantic search")
if response.intent_detected:
print(f"🎯 Intent: {response.intent_detected} (confidence: {response.intent_confidence:.2f})")
if response.awaiting_clarification:
print("⏳ Waiting for your response to complete the transaction...")
except KeyboardInterrupt:
print("\nπŸ‘‹ Goodbye!")
finally:
chatbot.close()
if __name__ == "__main__":
main()