From 65424c7db94e7f3d2d5688ddb27299226f4f342d Mon Sep 17 00:00:00 2001 From: malsony Date: Fri, 1 Dec 2023 16:09:15 +0800 Subject: [PATCH 1/3] Update xunfei_spark_bot.py update API URL for v3.0 version of Xunfei Spark. --- bot/xunfei/xunfei_spark_bot.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/bot/xunfei/xunfei_spark_bot.py b/bot/xunfei/xunfei_spark_bot.py index ed441bf..395d81e 100644 --- a/bot/xunfei/xunfei_spark_bot.py +++ b/bot/xunfei/xunfei_spark_bot.py @@ -40,10 +40,13 @@ class XunFeiBot(Bot): self.app_id = conf().get("xunfei_app_id") self.api_key = conf().get("xunfei_api_key") self.api_secret = conf().get("xunfei_api_secret") - # 默认使用v3.0版本,2.0版本可设置为generalv2, 1.5版本可设置为 general - self.domain = "generalv2" - # 默认使用v3.0版本,1.5版本可设置为 "ws://spark-api.xf-yun.com/v1.1/chat", - # 2.0版本可设置为 "ws://spark-api.xf-yun.com/v2.1/chat" + # 默认使用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" self.spark_url = "ws://spark-api.xf-yun.com/v3.1/chat" self.host = urlparse(self.spark_url).netloc self.path = urlparse(self.spark_url).path From f4f5be5b085ef9d03cdc9f74521fc22e2ceda258 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Mon, 4 Dec 2023 11:14:55 +0800 Subject: [PATCH 2/3] Create LICENSE --- lib/itchat/LICENSE | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 lib/itchat/LICENSE diff --git a/lib/itchat/LICENSE b/lib/itchat/LICENSE new file mode 100644 index 0000000..ba1a0e2 --- /dev/null +++ b/lib/itchat/LICENSE @@ -0,0 +1,9 @@ +**The MIT License (MIT)** + +Copyright (c) 2017 LittleCoder ([littlecodersh@Github](https://github.com/littlecodersh)) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From e5ba26febe8a61d460f2a611d37167ad20a75b82 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Wed, 6 Dec 2023 00:31:31 +0800 Subject: [PATCH 3/3] fix: tts voice base url --- bot/linkai/link_ai_bot.py | 4 +++- voice/openai/openai_voice.py | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bot/linkai/link_ai_bot.py b/bot/linkai/link_ai_bot.py index f308370..cd743b4 100644 --- a/bot/linkai/link_ai_bot.py +++ b/bot/linkai/link_ai_bot.py @@ -94,7 +94,7 @@ class LinkAIBot(Bot): file_id = context.kwargs.get("file_id") if file_id: body["file_id"] = file_id - logger.info(f"[LINKAI] query={query}, app_code={app_code}, mode={body.get('model')}, file_id={file_id}") + logger.info(f"[LINKAI] query={query}, app_code={app_code}, model={body.get('model')}, file_id={file_id}") headers = {"Authorization": "Bearer " + linkai_api_key} # do http request @@ -120,6 +120,8 @@ class LinkAIBot(Bot): if response["choices"][0].get("img_urls"): thread = threading.Thread(target=self._send_image, args=(context.get("channel"), context, response["choices"][0].get("img_urls"))) thread.start() + if response["choices"][0].get("text_content"): + reply_content = response["choices"][0].get("text_content") return Reply(ReplyType.TEXT, reply_content) else: diff --git a/voice/openai/openai_voice.py b/voice/openai/openai_voice.py index 2dd3cbe..767353e 100644 --- a/voice/openai/openai_voice.py +++ b/voice/openai/openai_voice.py @@ -33,7 +33,8 @@ class OpenaiVoice(Voice): def textToVoice(self, text): try: - url = 'https://api.openai.com/v1/audio/speech' + api_base = conf().get("open_ai_api_base") or "https://api.openai.com/v1" + url = f'{api_base}/audio/speech' headers = { 'Authorization': 'Bearer ' + conf().get("open_ai_api_key"), 'Content-Type': 'application/json'