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 HuggingFace model error. #3870

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions rag/llm/chat_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from openai import OpenAI
import openai
from ollama import Client
from rag.nlp import is_chinese
from rag.nlp import is_chinese, is_english
from rag.utils import num_tokens_from_string
from groq import Groq
import os
Expand Down Expand Up @@ -123,7 +123,7 @@ def __init__(self, key=None, model_name="", base_url=""):
raise ValueError("Local llm url cannot be None")
if base_url.split("/")[-1] != "v1":
base_url = os.path.join(base_url, "v1")
super().__init__(key, model_name, base_url)
super().__init__(key, model_name.split("___")[0], base_url)


class DeepSeekChat(Base):
Expand Down
3 changes: 2 additions & 1 deletion rag/llm/embedding_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ def __init__(self, key, model_name, base_url=None):
if not model_name:
raise ValueError("Model name cannot be None")
self.key = key
self.model_name = model_name
self.model_name = model_name.split("___")[0]
self.base_url = base_url or "http://127.0.0.1:8080"

def encode(self, texts: list):
Expand Down Expand Up @@ -775,6 +775,7 @@ def encode_queries(self, text):
else:
raise Exception(f"Error: {response.status_code} - {response.text}")


class VolcEngineEmbed(OpenAIEmbed):
def __init__(self, key, model_name, base_url="https://ark.cn-beijing.volces.com/api/v3"):
if not base_url:
Expand Down
2 changes: 1 addition & 1 deletion rag/llm/rerank_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def __init__(self, key, model_name, base_url):
"Content-Type": "application/json",
"Authorization": f"Bearer {key}"
}
self.model_name = model_name.replace("___LocalAI","")
self.model_name = model_name.split("___")[0]

def similarity(self, query: str, texts: list):
# noway to config Ragflow , use fix setting
Expand Down