mjpsm's picture
Upload 6 files
7e91a84 verified
Raw
History Blame Contribute Delete
480 Bytes
from contextlib import asynccontextmanager
from fastapi import FastAPI
from app.model_loader import load_model
from app.routes import router
@asynccontextmanager
async def lifespan(app: FastAPI):
tokenizer, model = load_model()
app.state.tokenizer = tokenizer
app.state.model = model
yield
app.state.tokenizer = None
app.state.model = None
app = FastAPI(
title="Qwen Bash Tool Calling API",
lifespan=lifespan,
)
app.include_router(router)