|
|
|
|
|
|
|
""" |
|
Code Review Agent - Main Entry Point |
|
|
|
This module serves as the entry point for the Code Review Agent application. |
|
It initializes the Gradio interface and starts the web server. |
|
""" |
|
|
|
import os |
|
import sys |
|
import logging |
|
from dotenv import load_dotenv |
|
|
|
|
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) |
|
|
|
|
|
from src.ui.gradio_app import create_gradio_app |
|
from src.core.agent_manager import AgentManager |
|
|
|
|
|
|
|
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 Code Review Agent application.""" |
|
|
|
load_dotenv() |
|
|
|
|
|
logs_dir = os.path.join(os.path.dirname(__file__), '..', 'logs') |
|
os.makedirs(logs_dir, exist_ok=True) |
|
|
|
|
|
agent_manager = AgentManager() |
|
|
|
|
|
app = create_gradio_app(agent_manager) |
|
|
|
|
|
app.launch(server_name="0.0.0.0", server_port=7860) |
|
|
|
|
|
if __name__ == "__main__": |
|
try: |
|
logger.info("Starting Code Review Agent application") |
|
main() |
|
except Exception as e: |
|
logger.exception(f"Error starting application: {e}") |
|
sys.exit(1) |