Spaces:
Sleeping
Sleeping
| #!/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() |