Spaces:
Sleeping
Sleeping
from contextlib import asynccontextmanager | |
from typing import Annotated | |
import dotenv | |
import uvicorn | |
import logging | |
import os | |
from fastapi import FastAPI, Depends | |
from fastapi.middleware.cors import CORSMiddleware | |
from common.common import configure_logging | |
from common.configuration import Configuration | |
# from main_before import config | |
# from routes.acronym import router as acronym_router | |
from common import dependencies as DI | |
from routes.dataset import router as dataset_router | |
from routes.document import router as document_router | |
from routes.acronym import router as acronym_router | |
from routes.llm import router as llm_router | |
from routes.llm_config import router as llm_config_router | |
from routes.llm_prompt import router as llm_prompt_router | |
from common.common import configure_logging | |
# Загружаем переменные из .env | |
dotenv.load_dotenv() | |
# from routes.feedback import router as feedback_router | |
# from routes.llm import router as llm_router | |
# from routes.log import router as log_router | |
CONFIG_PATH = os.environ.get('CONFIG_PATH', 'config_dev.yaml') | |
print("config path: ") | |
print(CONFIG_PATH) | |
config = Configuration(CONFIG_PATH) | |
logger = logging.getLogger(__name__) | |
configure_logging(config_file_path=config.common_config.log_file_path) | |
configure_logging( | |
level=logging.DEBUG, | |
config_file_path=config.common_config.log_file_path, | |
) | |
app = FastAPI(title="Assistant control panel") | |
origins = ["*"] | |
app.add_middleware( | |
CORSMiddleware, | |
allow_origins=origins, | |
allow_credentials=True, | |
allow_methods=["*"], | |
allow_headers=["*"], | |
) | |
app.include_router(llm_router) | |
# app.include_router(log_router) | |
# app.include_router(feedback_router) | |
app.include_router(acronym_router) | |
app.include_router(dataset_router) | |
app.include_router(document_router) | |
app.include_router(llm_config_router) | |
app.include_router(llm_prompt_router) | |
if __name__ == "__main__": | |
uvicorn.run( | |
"main:app", | |
host="localhost", | |
port=8885, | |
reload=True, | |
workers=1 | |
) |