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()