Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 11 additions & 37 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
"""Main entry point for the RAGAnything API."""

import asyncio
import logging
import logging.config
import sys
from contextlib import asynccontextmanager
from pathlib import Path

import uvicorn

logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
stream=sys.stdout,
force=True,
)

from alembic.config import Config
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
Expand All @@ -22,41 +29,8 @@
from application.api.query_routes import query_router
from dependencies import app_config, bm25_adapter, classical_vector_store

_LOG_FORMAT = "%(asctime)s %(levelname)-8s [%(name)s] %(message)s"

LOG_CONFIG = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"standard": {"format": _LOG_FORMAT},
},
"handlers": {
"console": {
"class": "logging.StreamHandler",
"formatter": "standard",
"stream": "ext://sys.stderr",
},
},
"loggers": {
"uvicorn": {"handlers": ["console"], "level": "INFO", "propagate": False},
"uvicorn.error": {"handlers": ["console"], "level": "INFO", "propagate": False},
"uvicorn.access": {
"handlers": ["console"],
"level": "INFO",
"propagate": False,
},
},
"root": {
"level": "INFO",
"handlers": ["console"],
},
}

logging.config.dictConfig(LOG_CONFIG)

logger = logging.getLogger(__name__)


def _run_alembic_upgrade() -> None:
"""Run Alembic migrations to head."""
alembic_dir = Path(__file__).parent
Expand Down Expand Up @@ -138,7 +112,7 @@ def run_fastapi():
host=app_config.HOST,
port=app_config.PORT,
log_level=app_config.UVICORN_LOG_LEVEL,
log_config=LOG_CONFIG,
log_config=None,
access_log=True,
ws="none",
)
Expand Down
Loading