From 936f27e9e5fea0731c9d96c589ed226b715bd9a2 Mon Sep 17 00:00:00 2001 From: Yongteng Lei Date: Mon, 8 Sep 2025 19:00:52 +0800 Subject: [PATCH] Feat: add LongCat-Flash-Chat (#9973) ### What problem does this PR solve? Add LongCat-Flash-Chat from Meituan, deepseek v3.1 from SiliconFlow, kimi-k2-09-05-preview and kimi-k2-turbo-preview from Moonshot. ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- conf/llm_factories.json | 43 ++++++++++++++++++++++++++++++ rag/llm/chat_model.py | 14 +++++++++- web/src/assets/svg/llm/longcat.svg | 7 +++++ web/src/constants/llm.ts | 2 ++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 web/src/assets/svg/llm/longcat.svg diff --git a/conf/llm_factories.json b/conf/llm_factories.json index 20d817df4..476307206 100644 --- a/conf/llm_factories.json +++ b/conf/llm_factories.json @@ -755,6 +755,20 @@ "model_type": "chat", "is_tools": true }, + { + "llm_name": "kimi-k2-0905-preview", + "tags": "LLM,CHAT,256k", + "max_tokens": 262144, + "model_type": "chat", + "is_tools": true + }, + { + "llm_name": "kimi-k2-turbo-preview", + "tags": "LLM,CHAT,256k", + "max_tokens": 262144, + "model_type": "chat", + "is_tools": true + }, { "llm_name": "kimi-latest", "tags": "LLM,CHAT,8k,32k,128k", @@ -2794,6 +2808,20 @@ "model_type": "chat", "is_tools": true }, + { + "llm_name": "Pro/deepseek-ai/DeepSeek-V3.1", + "tags": "LLM,CHAT,160k", + "max_tokens": 160000, + "model_type": "chat", + "is_tools": true + }, + { + "llm_name": "deepseek-ai/DeepSeek-V3.1", + "tags": "LLM,CHAT,160", + "max_tokens": 160000, + "model_type": "chat", + "is_tools": true + }, { "llm_name": "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B", "tags": "LLM,CHAT,32k", @@ -4448,6 +4476,21 @@ "is_tools": false } ] + }, + { + "name": "Meituan", + "logo": "", + "tags": "LLM", + "status": "1", + "llm": [ + { + "llm_name": "LongCat-Flash-Chat", + "tags": "LLM,CHAT,8000", + "max_tokens": 8000, + "model_type": "chat", + "is_tools": true + } + ] } ] } diff --git a/rag/llm/chat_model.py b/rag/llm/chat_model.py index adc4a3c5a..bb04b520c 100644 --- a/rag/llm/chat_model.py +++ b/rag/llm/chat_model.py @@ -155,7 +155,10 @@ class Base(ABC): def _chat_streamly(self, history, gen_conf, **kwargs): logging.info("[HISTORY STREAMLY]" + json.dumps(history, ensure_ascii=False, indent=4)) reasoning_start = False - response = self.client.chat.completions.create(model=self.model_name, messages=history, stream=True, **gen_conf, stop=kwargs.get("stop")) + if kwargs.get("stop") or "stop" in gen_conf: + response = self.client.chat.completions.create(model=self.model_name, messages=history, stream=True, **gen_conf, stop=kwargs.get("stop")) + else: + response = self.client.chat.completions.create(model=self.model_name, messages=history, stream=True, **gen_conf) for resp in response: if not resp.choices: continue @@ -1353,6 +1356,15 @@ class Ai302Chat(Base): super().__init__(key, model_name, base_url, **kwargs) +class MeituanChat(Base): + _FACTORY_NAME = "Meituan" + + def __init__(self, key, model_name, base_url="https://api.longcat.chat/openai", **kwargs): + if not base_url: + base_url = "https://api.longcat.chat/openai" + super().__init__(key, model_name, base_url, **kwargs) + + class LiteLLMBase(ABC): _FACTORY_NAME = ["Tongyi-Qianwen", "Bedrock", "Moonshot", "xAI", "DeepInfra", "Groq", "Cohere", "Gemini", "DeepSeek", "NVIDIA", "TogetherAI", "Anthropic", "Ollama"] diff --git a/web/src/assets/svg/llm/longcat.svg b/web/src/assets/svg/llm/longcat.svg new file mode 100644 index 000000000..f123daf3a --- /dev/null +++ b/web/src/assets/svg/llm/longcat.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/web/src/constants/llm.ts b/web/src/constants/llm.ts index 172c136e5..2fde6aced 100644 --- a/web/src/constants/llm.ts +++ b/web/src/constants/llm.ts @@ -54,6 +54,7 @@ export enum LLMFactory { DeepInfra = 'DeepInfra', Grok = 'Grok', XAI = 'xAI', + Meituan = 'Meituan', } // Please lowercase the file name @@ -113,4 +114,5 @@ export const IconMap = { [LLMFactory.DeepInfra]: 'deepinfra', [LLMFactory.Grok]: 'grok', [LLMFactory.XAI]: 'xai', + [LLMFactory.Meituan]: 'longcat', };