| """ |
| Zeta Researcher - Main application entry point. |
| |
| This module initializes and runs the FastAPI application with all components. |
| """ |
|
|
| import sys |
| import uvicorn |
| from pathlib import Path |
|
|
| |
| sys.path.insert(0, str(Path(__file__).parent)) |
|
|
| from src.config.settings import get_settings |
| from src.utils.logging import setup_logging, get_logger |
|
|
|
|
| def main(): |
| """Main application entry point.""" |
| |
| settings = get_settings() |
|
|
| |
| log_file = "logs/zeta_researcher.log" if not settings.debug else None |
| setup_logging( |
| log_level=settings.log_level, |
| log_file=log_file, |
| log_to_console=True |
| ) |
|
|
| logger = get_logger(__name__) |
| logger.info("=" * 60) |
| logger.info("Starting Zeta Researcher") |
| logger.info("=" * 60) |
| logger.info(f"Environment: {'Development' if settings.debug else 'Production'}") |
| logger.info(f"Default LLM: {settings.default_llm}") |
| logger.info(f"Embedding Model: {settings.embedding_model}") |
| logger.info(f"ChromaDB Path: {settings.chroma_persist_dir}") |
| logger.info(f"Server: http://{settings.host}:{settings.port}") |
| logger.info("=" * 60) |
|
|
| |
| |
| if settings.reload: |
| |
| try: |
| from src.api.routes import app |
| logger.info("FastAPI application loaded successfully") |
| uvicorn.run( |
| "src.api.routes:app", |
| host=settings.host, |
| port=settings.port, |
| reload=True, |
| log_level=settings.log_level.lower() |
| ) |
| except ImportError: |
| logger.warning("FastAPI routes not yet implemented - creating placeholder") |
| |
| from pathlib import Path |
| routes_dir = Path(__file__).parent / "src" / "api" |
| routes_dir.mkdir(parents=True, exist_ok=True) |
| routes_file = routes_dir / "routes.py" |
|
|
| if not routes_file.exists(): |
| routes_file.write_text('''""" |
| FastAPI routes placeholder. |
| """ |
| from fastapi import FastAPI |
| |
| app = FastAPI( |
| title="Zeta Researcher", |
| description="Local PDF Research Assistant with LLM Integration", |
| version="0.1.0" |
| ) |
| |
| @app.get("/") |
| async def root(): |
| return { |
| "message": "Zeta Researcher API", |
| "status": "Foundation setup complete", |
| "next_steps": "Implement PDF ingestion and RAG pipeline" |
| } |
| |
| @app.get("/health") |
| async def health(): |
| return {"status": "healthy"} |
| ''') |
|
|
| uvicorn.run( |
| "src.api.routes:app", |
| host=settings.host, |
| port=settings.port, |
| reload=True, |
| log_level=settings.log_level.lower() |
| ) |
| else: |
| |
| try: |
| from src.api.routes import app |
| logger.info("FastAPI application loaded successfully") |
| except ImportError: |
| logger.warning("FastAPI routes not yet implemented - using placeholder") |
| from fastapi import FastAPI |
| app = FastAPI( |
| title="Zeta Researcher", |
| description="Local PDF Research Assistant with LLM Integration", |
| version="0.1.0" |
| ) |
|
|
| @app.get("/") |
| async def root(): |
| return { |
| "message": "Zeta Researcher API", |
| "status": "Foundation setup complete", |
| "next_steps": "Implement PDF ingestion and RAG pipeline" |
| } |
|
|
| @app.get("/health") |
| async def health(): |
| return {"status": "healthy"} |
|
|
| uvicorn.run( |
| app, |
| host=settings.host, |
| port=settings.port, |
| log_level=settings.log_level.lower() |
| ) |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|