diff --git a/config.py b/config.py index 46b65787d..a9556830f 100644 --- a/config.py +++ b/config.py @@ -47,7 +47,7 @@ # "gpt-3.5-turbo-0613", "gpt-3.5-turbo-16k-0613", "gpt-3.5-turbo-0125" # "claude-3-haiku-20240307","claude-3-sonnet-20240229","claude-3-opus-20240229", "claude-2.1", "claude-instant-1.2", # "moss", "llama2", "chatglm_onnx", "internlm", "jittorllms_pangualpha", "jittorllms_llama", -# "yi-34b-chat-0205", "yi-34b-chat-200k" +# "yi-34b-chat-0205", "yi-34b-chat-200k", "deepseek-chat" ,"deepseek-coder" # ] # --- --- --- --- # 此外,您还可以在接入one-api/vllm/ollama时, @@ -223,6 +223,8 @@ # 零一万物(Yi Model) API KEY YIMODEL_API_KEY = "" +# 深度求索(DeepSeek) API KEY,默认请求地址为"https://api.deepseek.com/v1/chat/completions" +DEEPSEEK_API_KEY = "" # Mathpix 拥有执行PDF的OCR功能,但是需要注册账号 MATHPIX_APPID = "" diff --git a/request_llms/bridge_all.py b/request_llms/bridge_all.py index 979b0a138..648c4c22b 100644 --- a/request_llms/bridge_all.py +++ b/request_llms/bridge_all.py @@ -71,6 +71,7 @@ def decode(self, *args, **kwargs): cohere_endpoint = "https://api.cohere.ai/v1/chat" ollama_endpoint = "http://localhost:11434/api/chat" yimodel_endpoint = "https://api.lingyiwanwu.com/v1/chat/completions" +deepseekapi_endpoint = "https://api.deepseek.com/v1/chat/completions" if not AZURE_ENDPOINT.endswith('/'): AZURE_ENDPOINT += '/' azure_endpoint = AZURE_ENDPOINT + f'openai/deployments/{AZURE_ENGINE}/chat/completions?api-version=2023-05-15' @@ -91,6 +92,7 @@ def decode(self, *args, **kwargs): if cohere_endpoint in API_URL_REDIRECT: cohere_endpoint = API_URL_REDIRECT[cohere_endpoint] if ollama_endpoint in API_URL_REDIRECT: ollama_endpoint = API_URL_REDIRECT[ollama_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] # 获取tokenizer tokenizer_gpt35 = LazyloadTiktoken("gpt-3.5-turbo") @@ -795,8 +797,34 @@ def decode(self, *args, **kwargs): }) except: print(trimmed_format_exc()) - - +# -=-=-=-=-=-=- 幻方-深度求索大模型在线API -=-=-=-=-=-=- +if "deepseek-chat" in AVAIL_LLM_MODELS or "deepseek-coder" in AVAIL_LLM_MODELS: + try: + deepseekapi_noui, deepseekapi_ui = get_predict_function( + APIKEY="DEEPSEEK_API_KEY",token=4096,not_use_proxy=False + ) + model_info.update({ + "deepseek-chat":{ + "fn_with_ui": deepseekapi_ui, + "fn_without_ui": deepseekapi_noui, + "endpoint": deepseekapi_endpoint, + "can_multi_thread": True, + "max_token": 32000, + "tokenizer": tokenizer_gpt35, + "token_cnt": get_token_num_gpt35, + }, + "deepseek-coder":{ + "fn_with_ui": deepseekapi_ui, + "fn_without_ui": deepseekapi_noui, + "endpoint": deepseekapi_endpoint, + "can_multi_thread": True, + "max_token": 16000, + "tokenizer": tokenizer_gpt35, + "token_cnt": get_token_num_gpt35, + }, + }) + except: + print(trimmed_format_exc()) # -=-=-=-=-=-=- one-api 对齐支持 -=-=-=-=-=-=- for model in [m for m in AVAIL_LLM_MODELS if m.startswith("one-api-")]: # 为了更灵活地接入one-api多模型管理界面,设计了此接口,例子:AVAIL_LLM_MODELS = ["one-api-mixtral-8x7b(max_token=6666)"]