Skip to content

Commit e5b8251

Browse files
support chat model in huggingface
1 parent 5e7c1fb commit e5b8251

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

rag/llm/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
"BaiduYiyan": BaiduYiyanChat,
108108
"Anthropic": AnthropicChat,
109109
"Google Cloud": GoogleChat,
110+
"HuggingFace": HuggingFaceChat,
110111
}
111112

112113
RerankModel = {

rag/llm/chat_model.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,13 @@ def __init__(self, key=None, model_name="", base_url=""):
104104
if base_url.split("/")[-1] != "v1":
105105
base_url = os.path.join(base_url, "v1")
106106
super().__init__(key, model_name, base_url)
107-
107+
class HuggingFaceChat(Base):
108+
def __init__(self, key=None, model_name="", base_url=""):
109+
if not base_url:
110+
raise ValueError("Local llm url cannot be None")
111+
if base_url.split("/")[-1] != "v1":
112+
base_url = os.path.join(base_url, "v1")
113+
super().__init__(key, model_name, base_url)
108114

109115
class DeepSeekChat(Base):
110116
def __init__(self, key, model_name="deepseek-chat", base_url="https://api.deepseek.com/v1"):

web/src/pages/user-setting/setting-model/ollama-modal/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ const OllamaModal = ({
5454
llmFactoryToUrlMap[llmFactory as LlmFactory] ||
5555
'https://github.com/infiniflow/ragflow/blob/main/docs/guides/deploy_local_llm.mdx';
5656
const optionsMap = {
57-
HuggingFace: [{ value: 'embedding', label: 'embedding' }],
57+
HuggingFace: [
58+
{ value: 'embedding', label: 'embedding' },
59+
{ value: 'chat', label: 'chat' },
60+
],
5861
Xinference: [
5962
{ value: 'chat', label: 'chat' },
6063
{ value: 'embedding', label: 'embedding' },

0 commit comments

Comments
 (0)