from django.core.management.base import BaseCommand from ai_chatbot.models import GlobalQA from ai_chatbot.services import EmbeddingService class Command(BaseCommand): help = 'Setup global greeting Q&A for all properties' def handle(self, *args, **options): service = EmbeddingService() global_qa = [ # English Greetings ("Hello", "Hello! How can I help you with this property?", "en", 10), ("Hi", "Hi there! Feel free to ask me any questions about this property.", "en", 10), ("Hey", "Hey! How can I assist you today?", "en", 10), ("Good morning", "Good morning! How may I help you with this property?", "en", 9), ("Good afternoon", "Good afternoon! What would you like to know about this property?", "en", 9), ("Good evening", "Good evening! How can I assist you?", "en", 9), ("How are you?", "I'm doing great! How can I help you with this property?", "en", 8), ("Thanks", "You're welcome! Let me know if you have any other questions.", "en", 10), ("Thank you", "My pleasure! Feel free to ask anything else.", "en", 10), ("Thank you so much", "You're very welcome! Happy to help.", "en", 10), ("Ok thanks", "Anytime! Let me know if you need more information.", "en", 9), ("Bye", "Goodbye! Feel free to come back if you have more questions.", "en", 8), ("Goodbye", "Take care! Have a great day.", "en", 8), # Roman Urdu Greetings ("Assalam-o-Alaikum", "Wa Alaikum Assalam! Main ap ki kya madad kar sakta hoon?", "ur", 10), ("AoA", "Wa Alaikum Assalam! Kya sawal hai?", "ur", 10), ("Salam", "Wa Alaikum Assalam! Kaisay madad kar sakta hoon?", "ur", 10), ("Adaab", "Adaab! Kya poochna chahte ho property ke bare mein?", "ur", 9), ("Kya haal hai", "Allah ka shukar hai! Ap property ke bare mein kya poochna chahte ho?", "ur", 8), ("Theek ho", "Haan bilkul! Koi sawal poochain.", "ur", 8), ("Shukriya", "Apka khair maqdam hai! Koi aur sawal?", "ur", 10), ("Bohot shukriya", "Khushi hui madad karke! Aur poochain.", "ur", 10), ("Allah hafiz", "Allah hafiz! Phir kabhi ayen.", "ur", 8), # Mixed/Common ("Hello, kya haal hai", "Wa Alaikum Assalam! Mein theek hoon. Ap property ke bare mein kya janna chahte ho?", "both", 9), ("Hi, property available?", "Hello! Let me check the availability for you. Our agent will confirm shortly.", "both", 7), ("Salam, price kya hai", "Wa Alaikum Assalam! Please allow our agent to share detailed pricing information.", "both", 7), ] count = 0 for question, answer, language, priority in global_qa: embedding = service.generate_embedding(question) obj, created = GlobalQA.objects.get_or_create( question=question, defaults={ 'answer': answer, 'question_embedding': embedding, 'language': language, 'priority': priority, 'is_active': True } ) if created: count += 1 self.stdout.write(self.style.SUCCESS(f'āœ“ Added: {question[:40]}...')) else: # Update embedding if question exists obj.question_embedding = embedding obj.save() self.stdout.write(self.style.SUCCESS(f'\nāœ… Successfully added/updated {count} global Q&A pairs!'))