From b63c7496bae2e427f2bc2c4c3f8bc948d0bcbe1e Mon Sep 17 00:00:00 2001 From: Juan Calderon-Perez <835733+gaby@users.noreply.github.com> Date: Wed, 27 Dec 2023 00:02:08 -0500 Subject: [PATCH] Fix inefficent model check during chat creation (#1016) * Fix inefficent model check during chat creation * Update chat.py * Update chat.py --- api/src/serge/routers/chat.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/api/src/serge/routers/chat.py b/api/src/serge/routers/chat.py index 7cd0bd2..6de1568 100644 --- a/api/src/serge/routers/chat.py +++ b/api/src/serge/routers/chat.py @@ -1,3 +1,5 @@ +import os + from typing import Optional from fastapi import APIRouter, HTTPException from langchain.memory import RedisChatMessageHistory @@ -30,13 +32,8 @@ async def create_new_chat( init_prompt: str = "Below is an instruction that describes a task. Write a response that appropriately completes the request.", n_threads: int = 4, ): - try: - client = Llama( - model_path=f"/usr/src/app/weights/{model}.bin", - ) - del client - except Exception as exc: - raise ValueError(f"Model can't be found: {exc}") + if not os.path.exists(f"/usr/src/app/weights/{model}.bin"): + raise ValueError(f"Model can't be found: /usr/src/app/weights/{model}.bin") client = Redis(host="localhost", port=6379, decode_responses=False)