git-chat / run_local.py
lakkiroy's picture
Upload folder using huggingface_hub
200bf6d verified
#!/usr/bin/env python3
"""
Local development runner for the Chat with GitHub Repository application.
This script sets up the environment and runs the Gradio app locally.
"""
import os
import sys
from pathlib import Path
# Add the current directory to Python path
current_dir = Path(__file__).parent
sys.path.insert(0, str(current_dir))
def setup_environment():
"""Setup environment variables for local development"""
# Set default values if not already set
env_vars = {
"LLM_PROVIDER": "huggingface",
"EMBEDDING_PROVIDER": "sentence_transformers",
"HUGGINGFACE_MODEL": "microsoft/DialoGPT-medium",
"SENTENCE_TRANSFORMER_MODEL": "all-MiniLM-L6-v2",
"VECTOR_DB_PATH": "./chroma_db",
}
for key, value in env_vars.items():
if key not in os.environ:
os.environ[key] = value
# Create necessary directories
os.makedirs("chroma_db", exist_ok=True)
os.makedirs("models", exist_ok=True)
def main():
"""Main function to run the application"""
print("πŸš€ Starting Chat with GitHub Repository...")
print("πŸ“ Setting up environment...")
setup_environment()
print("πŸ€– Loading AI models (this may take a moment on first run)...")
# Import and run the app
try:
from app import demo
print("βœ… Application ready!")
print("🌐 Open your browser and go to the URL shown below:")
demo.launch(
server_name="0.0.0.0",
server_port=7860,
share=False,
debug=True
)
except ImportError as e:
print(f"❌ Error importing app: {e}")
print("πŸ’‘ Make sure you've installed all requirements: pip install -r requirements.txt")
sys.exit(1)
except Exception as e:
print(f"❌ Error starting application: {e}")
sys.exit(1)
if __name__ == "__main__":
main()