DonImages commited on
Commit
994ab9f
·
verified ·
1 Parent(s): 30fa026

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -3,12 +3,10 @@ import base64
3
  import os
4
  from contextlib import asynccontextmanager
5
 
6
- app = FastAPI()
7
-
8
  # Global variable to hold the LoRA weights
9
  lora_weights = None
10
 
11
- # Lifespan event to load the LoRA weights
12
  @asynccontextmanager
13
  async def lifespan(app: FastAPI):
14
  global lora_weights
@@ -22,7 +20,8 @@ async def lifespan(app: FastAPI):
22
  yield
23
  # Cleanup if necessary (but not required in this case)
24
 
25
- app.add_event_handler("lifespan", lifespan)
 
26
 
27
  @app.post("/modify-prompt")
28
  async def modify_prompt(prompt: str):
 
3
  import os
4
  from contextlib import asynccontextmanager
5
 
 
 
6
  # Global variable to hold the LoRA weights
7
  lora_weights = None
8
 
9
+ # Lifespan context manager to handle the application startup
10
  @asynccontextmanager
11
  async def lifespan(app: FastAPI):
12
  global lora_weights
 
20
  yield
21
  # Cleanup if necessary (but not required in this case)
22
 
23
+ # Initialize FastAPI app with lifespan context
24
+ app = FastAPI(lifespan=lifespan)
25
 
26
  @app.post("/modify-prompt")
27
  async def modify_prompt(prompt: str):