Merge pull request #213 from Ehco1996/patch-1

feat: support pass args before init web app
This commit is contained in:
hoshi-hiyouga 2023-07-20 22:12:07 +08:00 committed by GitHub
commit 6022adb72e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 4 deletions

View File

@ -30,9 +30,7 @@ async def lifespan(app: FastAPI): # collects GPU memory
torch_gc()
def create_app():
chat_model = ChatModel(*get_infer_args())
def create_app(chat_model: ChatModel):
app = FastAPI(lifespan=lifespan)
app.add_middleware(
@ -124,5 +122,6 @@ def create_app():
if __name__ == "__main__":
app = create_app()
chat_model = ChatModel(*get_infer_args())
app = create_app(chat_model)
uvicorn.run(app, host="0.0.0.0", port=8000, workers=1)