diff --git a/config.py b/config.py index 5e6b4752..913cf266 100644 --- a/config.py +++ b/config.py @@ -48,8 +48,8 @@ AVAIL_LLM_MODELS = ["qwen-max", "o1-mini", "o1-mini-2024-09-12", "o1", "o1-2024- "gemini-1.5-pro", "chatglm3", "chatglm4", "deepseek-chat", "deepseek-coder", "deepseek-reasoner", - "deepseek-ai/DeepSeek-R1","deepseek-ai/DeepSeek-V3", - "Qwen/Qwen2.5-32B-Instruct","Qwen/Qwen2.5-14B-Instruct","Qwen/Qwen2.5-7B-Instruct", + "siliconflow-deepseek-ai/DeepSeek-R1","siliconflow-deepseek-ai/DeepSeek-V3", "siliconflow-Qwen/QwQ-32B", + "siliconflow-Qwen/Qwen2.5-32B-Instruct","siliconflow-Qwen/Qwen2.5-14B-Instruct" "volcengine-deepseek-r1-250120", "volcengine-deepseek-v3-241226", "dashscope-deepseek-r1", "dashscope-deepseek-v3", ] @@ -77,10 +77,12 @@ EMBEDDING_MODEL = "text-embedding-3-small" # 使用"one-api-*","vllm-*","ollama-*","openrouter-*"前缀直接使用非标准方式接入的模型,例如 # AVAIL_LLM_MODELS = ["one-api-claude-3-sonnet-20240229(max_token=100000)", "ollama-phi3(max_token=4096)","openrouter-openai/gpt-4o-mini","openrouter-openai/chatgpt-4o-latest"] # --- --- --- --- -# 硅基智能(Siliconflow) API 可以通过 https://cloud.siliconflow.cn/models 或 https://docs.siliconflow.cn/api-reference/chat-completions/chat-completions 获取模型名称,并放置在AVAIL_LLM_MODELS列表中。 +# 硅基智能(Siliconflow) API 可以通过 https://cloud.siliconflow.cn/models 或 https://docs.siliconflow.cn/api-reference/chat-completions/chat-completions 获取模型名称 +# 在模型名称前添加"siliconflow-"前缀,并放置在AVAIL_LLM_MODELS列表中。 # AVAIL_LLM_MODELS = [ -# "deepseek-ai/DeepSeek-R1","deepseek-ai/DeepSeek-V3", -# "Qwen/Qwen2.5-32B-Instruct","Qwen/Qwen2.5-14B-Instruct","Qwen/Qwen2.5-7B-Instruct" +# "siliconflow-deepseek-ai/DeepSeek-R1","siliconflow-deepseek-ai/DeepSeek-V3", "siliconflow-Qwen/QwQ-32B", +# "siliconflow-Qwen/Qwen2.5-32B-Instruct","siliconflow-Qwen/Qwen2.5-14B-Instruct","siliconflow-Qwen/Qwen2.5-7B-Instruct", +# "siliconflow-THUDM/GLM-Z1-32B-0414" # ] # --- --- --- --- diff --git a/request_llms/bridge_all.py b/request_llms/bridge_all.py index c24e445e..2e5478b6 100644 --- a/request_llms/bridge_all.py +++ b/request_llms/bridge_all.py @@ -1343,65 +1343,41 @@ for model in [m for m in AVAIL_LLM_MODELS if m.startswith("openrouter-")]: # -=-=-=-=-=-=- 硅基智能SiliconFlow在线API -=-=-=-=-=-=- -siliconflow_models = [ - "deepseek-ai/DeepSeek-R1", "Pro/deepseek-ai/DeepSeek-R1", "deepseek-ai/DeepSeek-V3", "Pro/deepseek-ai/DeepSeek-V3", - "deepseek-ai/DeepSeek-R1-Distill-Llama-70B", "deepseek-ai/DeepSeek-R1-Distill-Qwen-32B", "deepseek-ai/DeepSeek-R1-Distill-Qwen-14B", - "deepseek-ai/DeepSeek-R1-Distill-Llama-8B", "deepseek-ai/DeepSeek-R1-Distill-Qwen-7B", "deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B", - "Pro/deepseek-ai/DeepSeek-R1-Distill-Llama-8B","Pro/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B","Pro/deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B", - "meta-llama/Llama-3.3-70B-Instruct","AIDC-AI/Marco-o1","deepseek-ai/DeepSeek-V2.5", - "Qwen/Qwen2.5-72B-Instruct-128K","Qwen/Qwen2.5-72B-Instruct","Qwen/Qwen2.5-32B-Instruct","Qwen/Qwen2.5-14B-Instruct","Qwen/Qwen2.5-7B-Instruct", - "Qwen/Qwen2.5-Coder-32B-Instruct","Qwen/Qwen2.5-Coder-7B-Instruct", - "Qwen/Qwen2-7B-Instruct","Qwen/Qwen2-1.5B-Instruct","Qwen/QwQ-32B-Preview", - "TeleAI/TeleChat2", - "01-ai/Yi-1.5-34B-Chat-16K","01-ai/Yi-1.5-9B-Chat-16K","01-ai/Yi-1.5-6B-Chat", - "THUDM/glm-4-9b-chat","Vendor-A/Qwen/Qwen2.5-72B-Instruct", - "internlm/internlm2_5-7b-chat","internlm/internlm2_5-20b-chat", - "nvidia/Llama-3.1-Nemotron-70B-Instruct", - "meta-llama/Meta-Llama-3.1-405B-Instruct","meta-llama/Meta-Llama-3.1-70B-Instruct","meta-llama/Meta-Llama-3.1-8B-Instruct", - "google/gemma-2-27b-it","google/gemma-2-9b-it", - "Pro/Qwen/Qwen2.5-7B-Instruct","Pro/Qwen/Qwen2-7B-Instruct","Pro/Qwen/Qwen2-1.5B-Instruct", - "Pro/THUDM/chatglm3-6b","Pro/THUDM/glm-4-9b-chat", - "Pro/meta-llama/Meta-Llama-3.1-8B-Instruct", - "Pro/google/gemma-2-9b-it", +# 支持推理的模型系列,非完整模型名称 +inference_model_series = [ + "THUDM/GLM-Z1", "deepseek-ai/DeepSeek-R1", "Qwen/QwQ-32B" ] - -if any(item in siliconflow_models for item in AVAIL_LLM_MODELS): +for model in [m for m in AVAIL_LLM_MODELS if m.startswith("siliconflow-")]: + # 模型名称的格式为: + # "siliconflow-" + # 其中: + # "siliconflow-" 是前缀(必要),在实际请求中,会将其去掉。 + # "deepseek-ai/DeepSeek-R1" 是硅基智能提供的模型名(必要)。 + try: siliconflow_noui, siliconflow_ui = get_predict_function( api_key_conf_name="SILICONFLOW_API_KEY", - max_output_token=4096, + max_output_token=8192, disable_proxy=False, + # 去除前缀 + model_remove_prefix = ["siliconflow-"] + ) + # 判断是否具有推理能力 + enable_reasoning = any(item in model for item in inference_model_series) + model_info.update( + { + model: { + "fn_with_ui": siliconflow_ui, + "fn_without_ui": siliconflow_noui, + "endpoint": siliconflow_endpoint, + "can_multi_thread": True, + "max_token": 32000, + "tokenizer": tokenizer_gpt35, + "token_cnt": get_token_num_gpt35, + "enable_reasoning": enable_reasoning, + }, + } ) - for item in (set(siliconflow_models) & set(AVAIL_LLM_MODELS)): - if "DeepSeek-R1" in item: - model_info.update( - { - item: { - "fn_with_ui": siliconflow_ui, - "fn_without_ui": siliconflow_noui, - "endpoint": siliconflow_endpoint, - "can_multi_thread": True, - "max_token": 8000, - "tokenizer": tokenizer_gpt35, - "token_cnt": get_token_num_gpt35, - "enable_reasoning": True, - }, - } - ) - else: - model_info.update( - { - item: { - "fn_with_ui": siliconflow_ui, - "fn_without_ui": siliconflow_noui, - "endpoint": siliconflow_endpoint, - "can_multi_thread": True, - "max_token": 8000, - "tokenizer": tokenizer_gpt35, - "token_cnt": get_token_num_gpt35, - }, - } - ) except: logger.error(trimmed_format_exc())