Kevin Hu
commited on
Commit
·
0dec4cf
1
Parent(s):
b8663aa
Fix HuggingFace model error. (#3870)
Browse files### What problem does this PR solve?
#3865
### Type of change
- [x] Bug Fix (non-breaking change which fixes an issue)
- rag/llm/chat_model.py +2 -2
- rag/llm/embedding_model.py +2 -1
- rag/llm/rerank_model.py +1 -1
rag/llm/chat_model.py
CHANGED
@@ -22,7 +22,7 @@ from abc import ABC
|
|
22 |
from openai import OpenAI
|
23 |
import openai
|
24 |
from ollama import Client
|
25 |
-
from rag.nlp import is_chinese
|
26 |
from rag.utils import num_tokens_from_string
|
27 |
from groq import Groq
|
28 |
import os
|
@@ -123,7 +123,7 @@ class HuggingFaceChat(Base):
|
|
123 |
raise ValueError("Local llm url cannot be None")
|
124 |
if base_url.split("/")[-1] != "v1":
|
125 |
base_url = os.path.join(base_url, "v1")
|
126 |
-
super().__init__(key, model_name, base_url)
|
127 |
|
128 |
|
129 |
class DeepSeekChat(Base):
|
|
|
22 |
from openai import OpenAI
|
23 |
import openai
|
24 |
from ollama import Client
|
25 |
+
from rag.nlp import is_chinese, is_english
|
26 |
from rag.utils import num_tokens_from_string
|
27 |
from groq import Groq
|
28 |
import os
|
|
|
123 |
raise ValueError("Local llm url cannot be None")
|
124 |
if base_url.split("/")[-1] != "v1":
|
125 |
base_url = os.path.join(base_url, "v1")
|
126 |
+
super().__init__(key, model_name.split("___")[0], base_url)
|
127 |
|
128 |
|
129 |
class DeepSeekChat(Base):
|
rag/llm/embedding_model.py
CHANGED
@@ -745,7 +745,7 @@ class HuggingFaceEmbed(Base):
|
|
745 |
if not model_name:
|
746 |
raise ValueError("Model name cannot be None")
|
747 |
self.key = key
|
748 |
-
self.model_name = model_name
|
749 |
self.base_url = base_url or "http://127.0.0.1:8080"
|
750 |
|
751 |
def encode(self, texts: list):
|
@@ -775,6 +775,7 @@ class HuggingFaceEmbed(Base):
|
|
775 |
else:
|
776 |
raise Exception(f"Error: {response.status_code} - {response.text}")
|
777 |
|
|
|
778 |
class VolcEngineEmbed(OpenAIEmbed):
|
779 |
def __init__(self, key, model_name, base_url="https://ark.cn-beijing.volces.com/api/v3"):
|
780 |
if not base_url:
|
|
|
745 |
if not model_name:
|
746 |
raise ValueError("Model name cannot be None")
|
747 |
self.key = key
|
748 |
+
self.model_name = model_name.split("___")[0]
|
749 |
self.base_url = base_url or "http://127.0.0.1:8080"
|
750 |
|
751 |
def encode(self, texts: list):
|
|
|
775 |
else:
|
776 |
raise Exception(f"Error: {response.status_code} - {response.text}")
|
777 |
|
778 |
+
|
779 |
class VolcEngineEmbed(OpenAIEmbed):
|
780 |
def __init__(self, key, model_name, base_url="https://ark.cn-beijing.volces.com/api/v3"):
|
781 |
if not base_url:
|
rag/llm/rerank_model.py
CHANGED
@@ -194,7 +194,7 @@ class LocalAIRerank(Base):
|
|
194 |
"Content-Type": "application/json",
|
195 |
"Authorization": f"Bearer {key}"
|
196 |
}
|
197 |
-
self.model_name = model_name.
|
198 |
|
199 |
def similarity(self, query: str, texts: list):
|
200 |
# noway to config Ragflow , use fix setting
|
|
|
194 |
"Content-Type": "application/json",
|
195 |
"Authorization": f"Bearer {key}"
|
196 |
}
|
197 |
+
self.model_name = model_name.split("___")[0]
|
198 |
|
199 |
def similarity(self, query: str, texts: list):
|
200 |
# noway to config Ragflow , use fix setting
|