From be125e27081427781674bfc12e6ee54ef382ce78 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Wed, 15 Nov 2023 15:48:33 -0800 Subject: [PATCH] Add /v1/internal/model/unload endpoint --- extensions/openai/script.py | 7 +++++++ 1 file changed, 7 insertions(+) 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))