| |
| """ |
| 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 |
|
|
| |
| current_dir = Path(__file__).parent |
| sys.path.insert(0, str(current_dir)) |
|
|
| def setup_environment(): |
| """Setup environment variables for local development""" |
| |
| 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 |
| |
| |
| 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)...") |
| |
| |
| 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() |