ReMind / src /main.py
GhostDragon01's picture
Add application file
368277b
"""
Main entry point for the Digital Assistant application.
A comprehensive assistant for bookmarks, email management, and web search.
Built with Smolagents and Gradio.
"""
import os
import sys
from dotenv import load_dotenv
def check_environment():
"""Check if all required environment variables are present"""
load_dotenv()
# Check for HF_TOKEN
if not os.getenv("HF_TOKEN"):
print("❌ Error: HF_TOKEN not found in environment variables.")
print("Please set your Hugging Face token in a .env file or as an environment variable.")
print("You can get your token from: https://huggingface.co/settings/tokens")
return False
# Check for Gmail OAuth credentials (environment variables)
google_client_id = os.getenv("GOOGLE_CLIENT_ID")
google_client_secret = os.getenv("GOOGLE_CLIENT_SECRET")
google_refresh_token = os.getenv("GOOGLE_REFRESH_TOKEN")
if not google_client_id or not google_client_secret:
print("⚠️ Warning: Gmail OAuth credentials not found in environment variables.")
print("Please set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET for Gmail integration.")
print("Run 'python scripts/setup_gmail_credentials.py' to set up Gmail credentials.")
elif not google_refresh_token:
print("⚠️ Warning: GOOGLE_REFRESH_TOKEN not found.")
print("Gmail integration may require re-authentication.")
print("Run 'python scripts/setup_gmail_credentials.py' to obtain the refresh token.")
else:
print("✅ Gmail OAuth credentials found in environment variables.")
return True
def main():
"""Main application entry point"""
print("🚀 Starting Digital Assistant...")
# Check environment
if not check_environment():
sys.exit(1)
try:
# Import here to avoid import errors before environment check
from src.interfaces.gradio_interface import demo
print("✅ Environment check passed")
print("🔖 Digital Assistant ready!")
print("🤔 Now with real-time thinking display!")
print("📧 Email • 🌐 Web Search • 🔖 Bookmarks")
print("🌐 Launching web interface...")
# Launch the interface
print("🌐 Access your assistant at: http://localhost:7860")
print("📱 A public URL will also be generated for external access")
print("🔧 The browser should open automatically")
demo.launch(
# share=True, # Set to True if you want a public URL
server_name="127.0.0.1", # Use localhost for better compatibility
server_port=7860,
show_error=True,
quiet=False,
inbrowser=True, # Automatically open browser
show_api=False,
)
except ImportError as e:
print(f"❌ Import error: {e}")
print("Please ensure all dependencies are installed: pip install -e .")
sys.exit(1)
except Exception as e:
print(f"❌ Error starting Digital Assistant: {e}")
sys.exit(1)
if __name__ == "__main__":
main()