Spaces:
Runtime error
Runtime error
File size: 1,577 Bytes
081c7ac 62ab01b 081c7ac 4d0ec3e 26e0ddc b1c8f17 2e76cf7 081c7ac 68394ea 081c7ac 7336259 68394ea 4d0ec3e 62ab01b 68394ea 081c7ac 68394ea 54210e7 4d0ec3e adb504f |
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 |
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from api.coding_assistant import v1 as coding_assistant_v1
from config import ALLOWED_ORIGINS
from database import init_db
from fastapi_cache import FastAPICache
from fastapi_cache.backends.inmemory import InMemoryBackend
import asyncio
import logging
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.FileHandler("app.log"),
logging.StreamHandler()
]
)
logger = logging.getLogger(__name__)
app = FastAPI()
# CORS middleware setup
app.add_middleware(
CORSMiddleware,
allow_origins=ALLOWED_ORIGINS,
allow_credentials=True,
allow_methods=["GET", "POST"],
allow_headers=["*"],
)
# Include routers
app.include_router(coding_assistant_v1.router)
# app.include_router(news_assistant_v1.router)
# app.include_router(search_assistant_v1.router)
# app.include_router(followup_agent_v1.router)
# app.include_router(followup_agent_v2.router)
# app.include_router(followup_agent_v3.router)
# app.include_router(followup_agent_v4.router)
# app.include_router(digiyatra_followup_v1.router)
@app.on_event("startup")
async def startup_event():
logger.info("Starting up the application")
FastAPICache.init(InMemoryBackend(), prefix="fastapi-cache")
asyncio.create_task(clear_inactive_conversations())
init_db()
if __name__ == "__main__":
import uvicorn
logger.info("Starting the application")
uvicorn.run(app, host="0.0.0.0", port=7860) |