Update app.py
Browse files12345678910111213142 unmodified lines171819202122from fastapi import FastAPI, HTTPExceptionimport base64import osapp = FastAPI()# Load LoRA weights on startuplora_weights = None@app.on_event("startup")def load_lora_weights():global lora_weightslora_path = "./lora_file.pth"if os.path.exists(lora_path):2 unmodified lineslora_weights = base64.b64encode(f.read()).decode("utf-8")print("LoRA weights loaded and preprocessed successfully.")else:raise HTTPException(status_code=500, detail="LoRA file not found.")@app.post("/modify-prompt")1234567891011121314151617181920212223242 unmodified lines27282930313233from fastapi import FastAPI, HTTPExceptionfrom fastapi.middleware.cors import CORSMiddlewareimport base64import osapp = FastAPI()# Middleware to handle CORS (optional, but useful if Testing4 calls this API)app.add_middleware(CORSMiddleware,allow_origins=["*"], # Adjust as needed for securityallow_credentials=True,allow_methods=["*"],allow_headers=["*"],)# Load LoRA weights globallylora_weights = None@app.on_event("startup")async def startup_event():global lora_weightslora_path = "./lora_file.pth"if os.path.exists(lora_path):2 unmodified lineslora_weights = base64.b64encode(f.read()).decode("utf-8")print("LoRA weights loaded and preprocessed successfully.")else:print("LoRA file not found during startup.")raise HTTPException(status_code=500, detail="LoRA file not found.")@app.post("/modify-prompt")
app.py+13-2