Spaces:
Sleeping
Sleeping
File size: 2,246 Bytes
401b16c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #!/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() |