Merge aa475a16e0 into be83907394
This commit is contained in:
commit
8ca6fe32d5
17
config.py
17
config.py
|
|
@ -16,6 +16,9 @@ DASHSCOPE_API_KEY = "" # 阿里灵积云API_KEY(用于接入qwen-max,dashsco
|
||||||
# [step 1-3]>> ( 接入 deepseek-reasoner, 即 deepseek-r1 ) 深度求索(DeepSeek) API KEY,默认请求地址为"https://api.deepseek.com/v1/chat/completions"
|
# [step 1-3]>> ( 接入 deepseek-reasoner, 即 deepseek-r1 ) 深度求索(DeepSeek) API KEY,默认请求地址为"https://api.deepseek.com/v1/chat/completions"
|
||||||
DEEPSEEK_API_KEY = ""
|
DEEPSEEK_API_KEY = ""
|
||||||
|
|
||||||
|
# [step 1-4]>> ( 接入 硅基智能API ) 硅基智能(Siliconflow) API KEY,默认请求地址为"https://api.siliconflow.cn/v1/chat/completions"
|
||||||
|
SILICONFLOW_API_KEY = ""
|
||||||
|
|
||||||
# [step 2]>> 改为True应用代理。如果使用本地或无地域限制的大模型时,此处不修改;如果直接在海外服务器部署,此处不修改
|
# [step 2]>> 改为True应用代理。如果使用本地或无地域限制的大模型时,此处不修改;如果直接在海外服务器部署,此处不修改
|
||||||
USE_PROXY = False
|
USE_PROXY = False
|
||||||
if USE_PROXY:
|
if USE_PROXY:
|
||||||
|
|
@ -29,7 +32,7 @@ if USE_PROXY:
|
||||||
"""
|
"""
|
||||||
proxies = {
|
proxies = {
|
||||||
# [协议]:// [地址] :[端口]
|
# [协议]:// [地址] :[端口]
|
||||||
"http": "socks5h://localhost:11284", # 再例如 "http": "http://127.0.0.1:7890",
|
"http": "socks5h://localhost:11284", # 再例如 "http": "http://127.0.0.1:7890",
|
||||||
"https": "socks5h://localhost:11284", # 再例如 "https": "http://127.0.0.1:7890",
|
"https": "socks5h://localhost:11284", # 再例如 "https": "http://127.0.0.1:7890",
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
|
|
@ -43,7 +46,10 @@ AVAIL_LLM_MODELS = ["qwen-max", "o1-mini", "o1-mini-2024-09-12", "o1", "o1-2024-
|
||||||
"gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5",
|
"gpt-3.5-turbo-1106", "gpt-3.5-turbo-16k", "gpt-3.5-turbo", "azure-gpt-3.5",
|
||||||
"gpt-4", "gpt-4-32k", "azure-gpt-4", "glm-4", "glm-4v", "glm-3-turbo",
|
"gpt-4", "gpt-4-32k", "azure-gpt-4", "glm-4", "glm-4v", "glm-3-turbo",
|
||||||
"gemini-1.5-pro", "chatglm3", "chatglm4",
|
"gemini-1.5-pro", "chatglm3", "chatglm4",
|
||||||
|
|
||||||
"deepseek-chat", "deepseek-coder", "deepseek-reasoner",
|
"deepseek-chat", "deepseek-coder", "deepseek-reasoner",
|
||||||
|
"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",
|
"volcengine-deepseek-r1-250120", "volcengine-deepseek-v3-241226",
|
||||||
"dashscope-deepseek-r1", "dashscope-deepseek-v3",
|
"dashscope-deepseek-r1", "dashscope-deepseek-v3",
|
||||||
"dashscope-qwen3-14b", "dashscope-qwen3-235b-a22b", "dashscope-qwen3-32b",
|
"dashscope-qwen3-14b", "dashscope-qwen3-235b-a22b", "dashscope-qwen3-32b",
|
||||||
|
|
@ -72,7 +78,14 @@ EMBEDDING_MODEL = "text-embedding-3-small"
|
||||||
# 使用"one-api-*","vllm-*","ollama-*","openrouter-*"前缀直接使用非标准方式接入的模型,例如
|
# 使用"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"]
|
# 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 获取模型名称
|
||||||
|
# 在模型名称前添加"siliconflow-"前缀,并放置在AVAIL_LLM_MODELS列表中。
|
||||||
|
# AVAIL_LLM_MODELS = [
|
||||||
|
# "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"
|
||||||
|
# ]
|
||||||
|
# --- --- --- ---
|
||||||
|
|
||||||
# --------------- 以下配置可以优化体验 ---------------
|
# --------------- 以下配置可以优化体验 ---------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,7 @@ ollama_endpoint = "http://localhost:11434/api/chat"
|
||||||
yimodel_endpoint = "https://api.lingyiwanwu.com/v1/chat/completions"
|
yimodel_endpoint = "https://api.lingyiwanwu.com/v1/chat/completions"
|
||||||
deepseekapi_endpoint = "https://api.deepseek.com/v1/chat/completions"
|
deepseekapi_endpoint = "https://api.deepseek.com/v1/chat/completions"
|
||||||
grok_model_endpoint = "https://api.x.ai/v1/chat/completions"
|
grok_model_endpoint = "https://api.x.ai/v1/chat/completions"
|
||||||
|
siliconflow_endpoint = "https://api.siliconflow.cn/v1/chat/completions"
|
||||||
volcengine_endpoint = "https://ark.cn-beijing.volces.com/api/v3/chat/completions"
|
volcengine_endpoint = "https://ark.cn-beijing.volces.com/api/v3/chat/completions"
|
||||||
|
|
||||||
if not AZURE_ENDPOINT.endswith('/'): AZURE_ENDPOINT += '/'
|
if not AZURE_ENDPOINT.endswith('/'): AZURE_ENDPOINT += '/'
|
||||||
|
|
@ -103,6 +104,7 @@ if ollama_endpoint in API_URL_REDIRECT: ollama_endpoint = API_URL_REDIRECT[ollam
|
||||||
if yimodel_endpoint in API_URL_REDIRECT: yimodel_endpoint = API_URL_REDIRECT[yimodel_endpoint]
|
if yimodel_endpoint in API_URL_REDIRECT: yimodel_endpoint = API_URL_REDIRECT[yimodel_endpoint]
|
||||||
if deepseekapi_endpoint in API_URL_REDIRECT: deepseekapi_endpoint = API_URL_REDIRECT[deepseekapi_endpoint]
|
if deepseekapi_endpoint in API_URL_REDIRECT: deepseekapi_endpoint = API_URL_REDIRECT[deepseekapi_endpoint]
|
||||||
if grok_model_endpoint in API_URL_REDIRECT: grok_model_endpoint = API_URL_REDIRECT[grok_model_endpoint]
|
if grok_model_endpoint in API_URL_REDIRECT: grok_model_endpoint = API_URL_REDIRECT[grok_model_endpoint]
|
||||||
|
if siliconflow_endpoint in API_URL_REDIRECT: siliconflow_endpoint = API_URL_REDIRECT[siliconflow_endpoint]
|
||||||
if volcengine_endpoint in API_URL_REDIRECT: volcengine_endpoint = API_URL_REDIRECT[volcengine_endpoint]
|
if volcengine_endpoint in API_URL_REDIRECT: volcengine_endpoint = API_URL_REDIRECT[volcengine_endpoint]
|
||||||
|
|
||||||
# 获取tokenizer
|
# 获取tokenizer
|
||||||
|
|
@ -315,6 +317,58 @@ model_info = {
|
||||||
"openai_force_temperature_one": True,
|
"openai_force_temperature_one": True,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"o4-mini": {
|
||||||
|
"fn_with_ui": chatgpt_ui,
|
||||||
|
"fn_without_ui": chatgpt_noui,
|
||||||
|
"has_multimodal_capacity": True,
|
||||||
|
"endpoint": openai_endpoint,
|
||||||
|
"max_token": 200000,
|
||||||
|
"tokenizer": tokenizer_gpt4,
|
||||||
|
"token_cnt": get_token_num_gpt4,
|
||||||
|
"openai_disable_system_prompt": True,
|
||||||
|
"openai_disable_stream": True,
|
||||||
|
"openai_force_temperature_one": True,
|
||||||
|
},
|
||||||
|
|
||||||
|
"gpt-4.1": {
|
||||||
|
"fn_with_ui": chatgpt_ui,
|
||||||
|
"fn_without_ui": chatgpt_noui,
|
||||||
|
"has_multimodal_capacity": True,
|
||||||
|
"endpoint": openai_endpoint,
|
||||||
|
"max_token": 200000,
|
||||||
|
"tokenizer": tokenizer_gpt4,
|
||||||
|
"token_cnt": get_token_num_gpt4,
|
||||||
|
"openai_disable_system_prompt": True,
|
||||||
|
"openai_disable_stream": True,
|
||||||
|
"openai_force_temperature_one": True,
|
||||||
|
},
|
||||||
|
|
||||||
|
"gpt-4.1-mini": {
|
||||||
|
"fn_with_ui": chatgpt_ui,
|
||||||
|
"fn_without_ui": chatgpt_noui,
|
||||||
|
"has_multimodal_capacity": True,
|
||||||
|
"endpoint": openai_endpoint,
|
||||||
|
"max_token": 200000,
|
||||||
|
"tokenizer": tokenizer_gpt4,
|
||||||
|
"token_cnt": get_token_num_gpt4,
|
||||||
|
"openai_disable_system_prompt": True,
|
||||||
|
"openai_disable_stream": True,
|
||||||
|
"openai_force_temperature_one": True,
|
||||||
|
},
|
||||||
|
|
||||||
|
"gpt-4.1-nano": {
|
||||||
|
"fn_with_ui": chatgpt_ui,
|
||||||
|
"fn_without_ui": chatgpt_noui,
|
||||||
|
"has_multimodal_capacity": True,
|
||||||
|
"endpoint": openai_endpoint,
|
||||||
|
"max_token": 200000,
|
||||||
|
"tokenizer": tokenizer_gpt4,
|
||||||
|
"token_cnt": get_token_num_gpt4,
|
||||||
|
"openai_disable_system_prompt": True,
|
||||||
|
"openai_disable_stream": True,
|
||||||
|
"openai_force_temperature_one": True,
|
||||||
|
},
|
||||||
|
|
||||||
"gpt-4.1":{
|
"gpt-4.1":{
|
||||||
"fn_with_ui": chatgpt_ui,
|
"fn_with_ui": chatgpt_ui,
|
||||||
"fn_without_ui": chatgpt_noui,
|
"fn_without_ui": chatgpt_noui,
|
||||||
|
|
@ -1416,6 +1470,47 @@ for model in [m for m in AVAIL_LLM_MODELS if m.startswith("openrouter-")]:
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
# -=-=-=-=-=-=- 硅基智能SiliconFlow在线API -=-=-=-=-=-=-
|
||||||
|
# 支持推理的模型系列,非完整模型名称
|
||||||
|
inference_model_series = [
|
||||||
|
"THUDM/GLM-Z1", "deepseek-ai/DeepSeek-R1", "Qwen/QwQ-32B"
|
||||||
|
]
|
||||||
|
for model in [m for m in AVAIL_LLM_MODELS if m.startswith("siliconflow-")]:
|
||||||
|
# 模型名称的格式为:
|
||||||
|
# "siliconflow-<model_name>"
|
||||||
|
# 其中:
|
||||||
|
# "siliconflow-" 是前缀(必要),在实际请求中,会将其去掉。
|
||||||
|
# "deepseek-ai/DeepSeek-R1" 是硅基智能提供的模型名(必要)。
|
||||||
|
|
||||||
|
try:
|
||||||
|
siliconflow_noui, siliconflow_ui = get_predict_function(
|
||||||
|
api_key_conf_name="SILICONFLOW_API_KEY",
|
||||||
|
# max_tokens 的说明:https://docs.siliconflow.cn/cn/faqs/misc
|
||||||
|
max_output_token=4096,
|
||||||
|
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,
|
||||||
|
"enable_reasoning": enable_reasoning,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
logger.info(f" siliconflow 模型 {model} 已加载")
|
||||||
|
|
||||||
|
except:
|
||||||
|
logger.error(trimmed_format_exc())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=-=-=
|
# -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=-=-=
|
||||||
# -=-=-=-=-=-=-=-=-=- ☝️ 以上是模型路由 -=-=-=-=-=-=-=-=-=
|
# -=-=-=-=-=-=-=-=-=- ☝️ 以上是模型路由 -=-=-=-=-=-=-=-=-=
|
||||||
# -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=-=-=
|
# -=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=--=-=-=-=-=-=-=-=
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue