File size: 672 Bytes
36ed17a
 
03beb83
 
 
36ed17a
 
 
 
 
 
 
 
 
 
03beb83
 
 
 
 
 
 
 
 
 
36ed17a
 
 
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
from fastapi import FastAPI
from app.api import chat
from app.db.database import Base, engine
from app.core.config import settings
from aiocache import caches

app = FastAPI()


# Create tables on startup
@app.on_event("startup")
async def startup():
    async with engine.begin() as conn:
        await conn.run_sync(Base.metadata.create_all)

    # Configure aiocache with in-memory backend
    caches.set_config(
        {
            "default": {
                "cache": settings.cache_backend,
                "ttl": 300,  # Default Time-To-Live for cache entries (in seconds)
            }
        }
    )


# Include the chat route
app.include_router(chat.router)