diff --git a/config.py b/config.py index f8e20d70..51f04d22 100644 --- a/config.py +++ b/config.py @@ -55,6 +55,7 @@ EMBEDDING_MODEL = "text-embedding-3-small" # "deepseek-chat" ,"deepseek-coder", # "gemini-1.5-flash", # "yi-34b-chat-0205","yi-34b-chat-200k","yi-large","yi-medium","yi-spark","yi-large-turbo","yi-large-preview", +# "grok-beta", # ] # --- --- --- --- # 此外,您还可以在接入one-api/vllm/ollama/Openroute时, @@ -234,7 +235,6 @@ MOONSHOT_API_KEY = "" # 零一万物(Yi Model) API KEY YIMODEL_API_KEY = "" - # 深度求索(DeepSeek) API KEY,默认请求地址为"https://api.deepseek.com/v1/chat/completions" DEEPSEEK_API_KEY = "" @@ -242,6 +242,8 @@ DEEPSEEK_API_KEY = "" # 紫东太初大模型 https://ai-maas.wair.ac.cn TAICHU_API_KEY = "" +# Grok API KEY +GROK_API_KEY = "" # Mathpix 拥有执行PDF的OCR功能,但是需要注册账号 MATHPIX_APPID = "" diff --git a/request_llms/bridge_all.py b/request_llms/bridge_all.py index 34d05cac..2c3cf14d 100644 --- a/request_llms/bridge_all.py +++ b/request_llms/bridge_all.py @@ -76,6 +76,7 @@ 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" +grok_model_endpoint = "https://api.x.ai/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' @@ -97,6 +98,7 @@ if cohere_endpoint in API_URL_REDIRECT: cohere_endpoint = API_URL_REDIRECT[coher 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] +if grok_model_endpoint in API_URL_REDIRECT: grok_model_endpoint = API_URL_REDIRECT[grok_model_endpoint] # 获取tokenizer tokenizer_gpt35 = LazyloadTiktoken("gpt-3.5-turbo") @@ -886,6 +888,31 @@ if any(item in yi_models for item in AVAIL_LLM_MODELS): }) except: logger.error(trimmed_format_exc()) + + +# -=-=-=-=-=-=- Grok model from x.ai -=-=-=-=-=-=- +grok_models = ["grok-beta"] +if any(item in grok_models for item in AVAIL_LLM_MODELS): + try: + grok_beta_128k_noui, grok_beta_128k_ui = get_predict_function( + api_key_conf_name="GROK_API_KEY", max_output_token=8192, disable_proxy=False + ) + + model_info.update({ + "grok-beta": { + "fn_with_ui": grok_beta_128k_ui, + "fn_without_ui": grok_beta_128k_noui, + "can_multi_thread": True, + "endpoint": grok_model_endpoint, + "max_token": 128000, + "tokenizer": tokenizer_gpt35, + "token_cnt": get_token_num_gpt35, + }, + + }) + except: + logger.error(trimmed_format_exc()) + # -=-=-=-=-=-=- 讯飞星火认知大模型 -=-=-=-=-=-=- if "spark" in AVAIL_LLM_MODELS: try: