diff --git a/extensions/openai/script.py b/extensions/openai/script.py index fd124b5f..ec0ceeef 100644 --- a/extensions/openai/script.py +++ b/extensions/openai/script.py @@ -20,6 +20,7 @@ from fastapi.requests import Request from fastapi.responses import JSONResponse from modules import shared from modules.logging_colors import logger +from modules.models import unload_model from modules.text_generation import stop_everything_event from pydub import AudioSegment from sse_starlette import EventSourceResponse @@ -285,6 +286,12 @@ async def handle_load_model(request_data: LoadModelRequest): return HTTPException(status_code=400, detail="Failed to load the model.") +@app.post("/v1/internal/model/unload") +async def handle_load_model(): + unload_model() + return JSONResponse(content="OK") + + def run_server(): server_addr = '0.0.0.0' if shared.args.listen else '127.0.0.1' port = int(os.environ.get('OPENEDAI_PORT', shared.args.api_port))