File size: 1,828 Bytes
67753ad
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
Agent By Parmar For Code Review - Main Entry Point

This module serves as the entry point for the Agent By Parmar For Code Review application.
It initializes the Gradio interface and starts the web server.
"""

import os
import sys
import logging
from dotenv import load_dotenv

# Add the project root to the Python path
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

# Import application modules
from src.ui.gradio_app import create_gradio_app
from src.core.agent_manager import AgentManager

# Configure logging
# Create logs directory if it doesn't exist
logs_dir = os.path.join(os.path.dirname(__file__), '..', 'logs')
os.makedirs(logs_dir, exist_ok=True)

logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    handlers=[
        logging.StreamHandler(),
        logging.FileHandler(os.path.join(logs_dir, 'app.log'), mode='a')
    ]
)

logger = logging.getLogger(__name__)


def main():
    """Main function to start the Agent By Parmar For Code Review application."""
    # Load environment variables
    load_dotenv()
    
    # Create logs directory if it doesn't exist
    logs_dir = os.path.join(os.path.dirname(__file__), '..', 'logs')
    os.makedirs(logs_dir, exist_ok=True)
    
    # Initialize the agent manager
    agent_manager = AgentManager()
    
    # Create and launch the Gradio app
    app = create_gradio_app(agent_manager)
    
    # Start the Gradio server
    app.launch(server_name="0.0.0.0", server_port=7860)


if __name__ == "__main__":
    try:
        logger.info("Starting Agent By Parmar For Code Review application")
        main()
    except Exception as e:
        logger.exception(f"Error starting application: {e}")
        sys.exit(1)