From c415485801da3e1b7062b98e00b6a314616195d6 Mon Sep 17 00:00:00 2001 From: 6vision Date: Thu, 1 Aug 2024 17:57:48 +0800 Subject: [PATCH] Support Spark4.0 Ultra model, optimize model configuration. --- bot/xunfei/xunfei_spark_bot.py | 17 +++++++++-------- config.py | 2 ++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/bot/xunfei/xunfei_spark_bot.py b/bot/xunfei/xunfei_spark_bot.py index 9ca6b96..e9065e1 100644 --- a/bot/xunfei/xunfei_spark_bot.py +++ b/bot/xunfei/xunfei_spark_bot.py @@ -41,14 +41,15 @@ class XunFeiBot(Bot): self.api_key = conf().get("xunfei_api_key") self.api_secret = conf().get("xunfei_api_secret") # 默认使用v2.0版本: "generalv2" - # v1.5版本为 "general" - # v3.0版本为: "generalv3" - self.domain = "generalv3" - # 默认使用v2.0版本: "ws://spark-api.xf-yun.com/v2.1/chat" - # v1.5版本为: "ws://spark-api.xf-yun.com/v1.1/chat" - # v3.0版本为: "ws://spark-api.xf-yun.com/v3.1/chat" - # v3.5版本为: "wss://spark-api.xf-yun.com/v3.5/chat" - self.spark_url = "wss://spark-api.xf-yun.com/v3.5/chat" + # Spark Lite请求地址(spark_url): wss://spark-api.xf-yun.com/v1.1/chat, 对应的domain参数为: "general" + # Spark V2.0请求地址(spark_url): wss://spark-api.xf-yun.com/v2.1/chat, 对应的domain参数为: "generalv2" + # Spark Pro 请求地址(spark_url): wss://spark-api.xf-yun.com/v3.1/chat, 对应的domain参数为: "generalv3" + # Spark Pro-128K请求地址(spark_url): wss://spark-api.xf-yun.com/chat/pro-128k, 对应的domain参数为: "pro-128k" + # Spark Max 请求地址(spark_url): wss://spark-api.xf-yun.com/v3.5/chat, 对应的domain参数为: "generalv3.5" + # Spark4.0 Ultra 请求地址(spark_url): wss://spark-api.xf-yun.com/v4.0/chat, 对应的domain参数为: "4.0Ultra" + # 后续模型更新,对应的参数可以参考官网文档获取:https://www.xfyun.cn/doc/spark/Web.html + self.domain = conf().get("xunfei_domain", "generalv3.5") + self.spark_url = conf().get("xunfei_spark_url", "wss://spark-api.xf-yun.com/v3.5/chat") self.host = urlparse(self.spark_url).netloc self.path = urlparse(self.spark_url).path # 和wenxin使用相同的session机制 diff --git a/config.py b/config.py index cad6872..b6ae49e 100644 --- a/config.py +++ b/config.py @@ -73,6 +73,8 @@ available_setting = { "xunfei_app_id": "", # 讯飞应用ID "xunfei_api_key": "", # 讯飞 API key "xunfei_api_secret": "", # 讯飞 API secret + "xunfei_domain": "", # 讯飞模型对应的domain参数,Spark4.0 Ultra为 4.0Ultra,其他模型详见: https://www.xfyun.cn/doc/spark/Web.html + "xunfei_spark_url": "", # 讯飞模型对应的请求地址,Spark4.0 Ultra为 wss://spark-api.xf-yun.com/v4.0/chat,其他模型参考详见: https://www.xfyun.cn/doc/spark/Web.html # claude 配置 "claude_api_cookie": "", "claude_uuid": "",