diff --git a/api/apps/llm_app.py b/api/apps/llm_app.py index c982f4b36..71b6affc8 100644 --- a/api/apps/llm_app.py +++ b/api/apps/llm_app.py @@ -360,4 +360,4 @@ def list_app(): return get_json_result(data=res) except Exception as e: - return server_error_response(e) \ No newline at end of file + return server_error_response(e) diff --git a/conf/llm_factories.json b/conf/llm_factories.json index acb878bcb..469bde9fa 100644 --- a/conf/llm_factories.json +++ b/conf/llm_factories.json @@ -295,6 +295,13 @@ "status": "1", "llm": [] }, + { + "name": "ModelScope", + "logo": "", + "tags": "LLM", + "status": "1", + "llm": [] + }, { "name": "LocalAI", "logo": "", diff --git a/docs/references/supported_models.mdx b/docs/references/supported_models.mdx index 98511517c..ebe9bb691 100644 --- a/docs/references/supported_models.mdx +++ b/docs/references/supported_models.mdx @@ -35,6 +35,7 @@ A complete list of models supported by RAGFlow, which will continue to expand. | LM-Studio | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | | | MiniMax | :heavy_check_mark: | | | | | | | Mistral | :heavy_check_mark: | :heavy_check_mark: | | | | | +| ModelScope | :heavy_check_mark: | | | | | | | Moonshot | :heavy_check_mark: | | | :heavy_check_mark: | | | | novita.ai | :heavy_check_mark: | | | | | | | NVIDIA | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | | @@ -70,4 +71,4 @@ If your model is not listed here but has APIs compatible with those of OpenAI, c :::note The list of supported models is extracted from [this source](https://github.com/infiniflow/ragflow/blob/main/rag/llm/__init__.py) and may not be the most current. For the latest supported model list, please refer to the Python file. -::: \ No newline at end of file +::: diff --git a/rag/llm/__init__.py b/rag/llm/__init__.py index bb3ba64ee..2c514d4b5 100644 --- a/rag/llm/__init__.py +++ b/rag/llm/__init__.py @@ -85,6 +85,7 @@ from .chat_model import ( GoogleChat, HuggingFaceChat, GPUStackChat, + ModelScopeChat, ) from .cv_model import ( @@ -231,6 +232,7 @@ ChatModel = { "Google Cloud": GoogleChat, "HuggingFace": HuggingFaceChat, "GPUStack": GPUStackChat, + "ModelScope":ModelScopeChat, } RerankModel = { diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py index a931360db..9286d369c 100644 --- a/rag/llm/chat_model.py +++ b/rag/llm/chat_model.py @@ -143,6 +143,16 @@ class HuggingFaceChat(Base): super().__init__(key, model_name.split("___")[0], base_url) +class ModelScopeChat(Base): + def __init__(self, key=None, model_name="", base_url=""): + if not base_url: + raise ValueError("Local llm url cannot be None") + base_url = base_url.rstrip('/') + if base_url.split("/")[-1] != "v1": + base_url = os.path.join(base_url, "v1") + super().__init__(key, model_name.split("___")[0], base_url) + + class DeepSeekChat(Base): def __init__(self, key, model_name="deepseek-chat", base_url="https://api.deepseek.com/v1"): if not base_url: @@ -1537,4 +1547,4 @@ class GPUStackChat(Base): raise ValueError("Local llm url cannot be None") if base_url.split("/")[-1] != "v1-openai": base_url = os.path.join(base_url, "v1-openai") - super().__init__(key, model_name, base_url) \ No newline at end of file + super().__init__(key, model_name, base_url) diff --git a/web/src/assets/svg/llm/modelscope.svg b/web/src/assets/svg/llm/modelscope.svg new file mode 100644 index 000000000..8b3778fc4 --- /dev/null +++ b/web/src/assets/svg/llm/modelscope.svg @@ -0,0 +1 @@ + diff --git a/web/src/constants/setting.ts b/web/src/constants/setting.ts index ed1165634..6cc47f65a 100644 --- a/web/src/constants/setting.ts +++ b/web/src/constants/setting.ts @@ -33,6 +33,7 @@ export const IconMap = { 文心一言: 'wenxin', Ollama: 'ollama', Xinference: 'xinference', + ModelScope: 'modelscope', DeepSeek: 'deepseek', VolcEngine: 'volc_engine', BaiChuan: 'baichuan', diff --git a/web/src/pages/user-setting/constants.tsx b/web/src/pages/user-setting/constants.tsx index 255cb4a5e..df482c4ef 100644 --- a/web/src/pages/user-setting/constants.tsx +++ b/web/src/pages/user-setting/constants.tsx @@ -32,6 +32,7 @@ export const LocalLlmFactories = [ 'OpenRouter', 'HuggingFace', 'GPUStack', + 'ModelScope', ]; export enum TenantRole { 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 b68913a2c..97bb9a3e2 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 @@ -21,6 +21,7 @@ const llmFactoryToUrlMap = { Ollama: 'https://github.com/infiniflow/ragflow/blob/main/docs/guides/deploy_local_llm.mdx', Xinference: 'https://inference.readthedocs.io/en/latest/user_guide', + ModelScope: 'https://www.modelscope.cn/docs/model-service/API-Inference/intro', LocalAI: 'https://localai.io/docs/getting-started/models/', 'LM-Studio': 'https://lmstudio.ai/docs/basics', 'OpenAI-API-Compatible': 'https://platform.openai.com/docs/models/gpt-4', @@ -77,6 +78,9 @@ const OllamaModal = ({ { value: 'speech2text', label: 'sequence2text' }, { value: 'tts', label: 'tts' }, ], + ModelScope: [ + { value: 'chat', label: 'chat' }, + ], GPUStack: [ { value: 'chat', label: 'chat' }, { value: 'embedding', label: 'embedding' },