From 60428c4ad2033ae5a010166d2cc375abcab8c7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=85=BE?= <101850389+hangters@users.noreply.github.com> Date: Wed, 7 Aug 2024 18:10:42 +0800 Subject: [PATCH] fix LocalAI add bug (#1851) ### What problem does this PR solve? #1848 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --------- Co-authored-by: Zhedong Cen --- rag/llm/chat_model.py | 6 +++--- rag/llm/embedding_model.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py index 40dbff1117..2b5ab68dde 100644 --- a/rag/llm/chat_model.py +++ b/rag/llm/chat_model.py @@ -102,7 +102,7 @@ def __init__(self, key=None, model_name="", base_url=""): if not base_url: raise ValueError("Local llm url cannot be None") if base_url.split("/")[-1] != "v1": - self.base_url = os.path.join(base_url, "v1") + base_url = os.path.join(base_url, "v1") key = "xxx" super().__init__(key, model_name, base_url) @@ -373,8 +373,8 @@ def __init__(self, key, model_name, base_url): if not base_url: raise ValueError("Local llm url cannot be None") if base_url.split("/")[-1] != "v1": - self.base_url = os.path.join(base_url, "v1") - self.client = OpenAI(api_key="empty", base_url=self.base_url) + base_url = os.path.join(base_url, "v1") + self.client = OpenAI(api_key="empty", base_url=base_url) self.model_name = model_name.split("___")[0] diff --git a/rag/llm/embedding_model.py b/rag/llm/embedding_model.py index 3c3a018d43..3b0ef5f715 100644 --- a/rag/llm/embedding_model.py +++ b/rag/llm/embedding_model.py @@ -510,8 +510,8 @@ def __init__(self, key, model_name, base_url): if not base_url: raise ValueError("Local llm url cannot be None") if base_url.split("/")[-1] != "v1": - self.base_url = os.path.join(base_url, "v1") - self.client = OpenAI(api_key="lm-studio", base_url=self.base_url) + base_url = os.path.join(base_url, "v1") + self.client = OpenAI(api_key="lm-studio", base_url=base_url) self.model_name = model_name @@ -520,6 +520,6 @@ def __init__(self, key, model_name, base_url): if not base_url: raise ValueError("url cannot be None") if base_url.split("/")[-1] != "v1": - self.base_url = os.path.join(base_url, "v1") + base_url = os.path.join(base_url, "v1") self.client = OpenAI(api_key=key, base_url=base_url) self.model_name = model_name.split("___")[0] \ No newline at end of file