Spaces:
Running
Running
| #!/usr/bin/env python3 | |
| """ | |
| Script to create AIDA_BOT user in the database | |
| This ensures AIDA appears correctly in conversations with name and avatar | |
| """ | |
| import asyncio | |
| import sys | |
| from pathlib import Path | |
| from datetime import datetime | |
| # Add parent directory to path | |
| sys.path.insert(0, str(Path(__file__).parent.parent)) | |
| from app.database import connect_db, disconnect_db, get_db | |
| import logging | |
| logging.basicConfig(level=logging.INFO) | |
| logger = logging.getLogger(__name__) | |
| # AIDA Bot configuration | |
| AIDA_BOT_ID = "AIDA_BOT" | |
| AIDA_AVATAR_URL = "https://imagedelivery.net/0utJlkqgAVuawL5OpMWxgw/aida-bot-avatar/public" # You can update this | |
| async def create_aida_bot_user(): | |
| """Create or update AIDA_BOT user in the database""" | |
| try: | |
| # Connect to database | |
| await connect_db() | |
| db = await get_db() | |
| # Check if AIDA_BOT already exists | |
| existing = await db.users.find_one({"_id": AIDA_BOT_ID}) | |
| if existing: | |
| logger.info(f"AIDA_BOT user already exists: {existing.get('name')}") | |
| # Update to ensure correct data | |
| await db.users.update_one( | |
| {"_id": AIDA_BOT_ID}, | |
| {"$set": { | |
| "name": "AIDA", | |
| "email": "aida@lojiz.com", | |
| "role": "bot", | |
| "profilePicture": AIDA_AVATAR_URL, | |
| "isActive": True, | |
| "updated_at": datetime.utcnow() | |
| }} | |
| ) | |
| logger.info("✅ AIDA_BOT user updated successfully") | |
| else: | |
| # Create new AIDA_BOT user | |
| aida_user = { | |
| "_id": AIDA_BOT_ID, | |
| "name": "AIDA", | |
| "email": "aida@lojiz.com", | |
| "role": "bot", # Special role for bots | |
| "profilePicture": AIDA_AVATAR_URL, | |
| "bio": "Your AI property assistant. I help you find properties, create listings, and answer questions about real estate.", | |
| "isActive": True, | |
| "isEmailVerified": True, | |
| "isPhoneVerified": False, | |
| "createdAt": datetime.utcnow(), | |
| "updated_at": datetime.utcnow(), | |
| "totalListings": 0, | |
| "totalReviews": 0, | |
| "averageRating": 5.0, | |
| } | |
| await db.users.insert_one(aida_user) | |
| logger.info("✅ AIDA_BOT user created successfully") | |
| logger.info(f"\n{'='*60}") | |
| logger.info(f"AIDA Bot User Details:") | |
| logger.info(f" ID: {AIDA_BOT_ID}") | |
| logger.info(f" Name: AIDA") | |
| logger.info(f" Avatar: {AIDA_AVATAR_URL}") | |
| logger.info(f"{'='*60}\n") | |
| except Exception as e: | |
| logger.error(f"Failed to create AIDA_BOT user: {e}") | |
| raise | |
| finally: | |
| await disconnect_db() | |
| if __name__ == "__main__": | |
| logger.info("Creating AIDA_BOT user...") | |
| asyncio.run(create_aida_bot_user()) | |