2B / app.py
37-AN
Initial commit for Hugging Face Space deployment
c7d6600
raw
history blame
894 Bytes
#!/usr/bin/env python
"""
Main entry point for Hugging Face Spaces deployment.
This file starts the Streamlit UI when deployed to Hugging Face Spaces.
"""
import subprocess
import os
import sys
# Make sure the app directory is in the path
# Add the current directory to the path so that 'app' is recognized as a package
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
# Also add the parent directory to path to ensure imports work properly
sys.path.append(os.path.abspath('.'))
# Create necessary directories
os.makedirs('data/documents', exist_ok=True)
os.makedirs('data/vector_db', exist_ok=True)
# Set environment variable for Python path
os.environ['PYTHONPATH'] = os.path.abspath('.')
# Run the Streamlit app with specific port to match huggingface-space.yml
subprocess.run(["streamlit", "run", "app/ui/streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"])