Fix inefficent model check during chat creation (#1016)

* Fix inefficent model check during chat creation

* Update chat.py

* Update chat.py
This commit is contained in:
Juan Calderon-Perez
2023-12-27 00:02:08 -05:00
committed by GitHub
parent 586f556577
commit b63c7496ba

View File

@@ -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)