Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inefficient model check during chat creation #1016

Merged
merged 3 commits into from
Dec 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions api/src/serge/routers/chat.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from typing import Optional
from fastapi import APIRouter, HTTPException
from langchain.memory import RedisChatMessageHistory
Expand Down Expand Up @@ -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)

Expand Down