OAI: Migrate model depends into proper file

Use amongst multiple routers.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2024-07-23 12:40:32 -04:00
parent d1706fb067
commit 64c2cc85c9
2 changed files with 15 additions and 14 deletions

View file

@ -7,6 +7,7 @@ from sys import maxsize
from common import config, model, sampling
from common.auth import check_admin_key, check_api_key, get_key_permission
from common.downloader import hf_repo_download
from common.model import check_model_container
from common.networking import handle_request_error, run_with_request_disconnect
from common.templating import PromptTemplate, get_all_templates
from common.utils import unwrap
@ -60,20 +61,6 @@ from endpoints.OAI.utils.lora import get_active_loras, get_lora_list
router = APIRouter()
async def check_model_container():
"""FastAPI depends that checks if a model isn't loaded or currently loading."""
if model.container is None or not (
model.container.model_is_loading or model.container.model_loaded
):
error_message = handle_request_error(
"No models are currently loaded.",
exc_info=False,
).error.message
raise HTTPException(400, error_message)
# Completions endpoint
@router.post(
"/v1/completions",