Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

support chat model in huggingface (#2802)

JobSmithManipulation3f065c75da22
diff --git a/rag/llm/__init__.py b/rag/llm/__init__.py
index c7a820d2fd..8ad059fb00 100644
--- a/rag/llm/__init__.py
+++ b/rag/llm/__init__.py
@@ -107,6 +107,7 @@ ChatModel = {
"BaiduYiyan": BaiduYiyanChat,
"Anthropic": AnthropicChat,
"Google Cloud": GoogleChat,
+ "HuggingFace": HuggingFaceChat,
}
RerankModel = {
diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py
index d18fc02e97..bf91dbf0f2 100644
--- a/rag/llm/chat_model.py
+++ b/rag/llm/chat_model.py
@@ -104,7 +104,13 @@ class XinferenceChat(Base):
if base_url.split("/")[-1] != "v1":
base_url = os.path.join(base_url, "v1")
super().__init__(key, model_name, base_url)
-
+class HuggingFaceChat(Base):
+ 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":
+ base_url = os.path.join(base_url, "v1")
+ super().__init__(key, model_name, base_url)
class DeepSeekChat(Base):
def __init__(self, key, model_name="deepseek-chat", base_url="https://api.deepseek.com/v1"):
diff --git a/web/src/pages/user-setting/setting-model/ollama-modal/index.tsx b/web/src/pages/user-setting/setting-model/ollama-modal/index.tsx
index c372b2f3fa..18bcdb6c59 100644
--- a/web/src/pages/user-setting/setting-model/ollama-modal/index.tsx
+++ b/web/src/pages/user-setting/setting-model/ollama-modal/index.tsx
@@ -54,7 +54,10 @@ const OllamaModal = ({
llmFactoryToUrlMap[llmFactory as LlmFactory] ||
'https://github.com/infiniflow/ragflow/blob/main/docs/guides/deploy_local_llm.mdx';
const optionsMap = {
- HuggingFace: [{ value: 'embedding', label: 'embedding' }],
+ HuggingFace: [
+ { value: 'embedding', label: 'embedding' },
+ { value: 'chat', label: 'chat' },
+ ],
Xinference: [
{ value: 'chat', label: 'chat' },
{ value: 'embedding', label: 'embedding' },