From 1b48cea50a851fb6057a4f8dac730c2bd63f4b49 Mon Sep 17 00:00:00 2001 From: zouyq Date: Thu, 10 Aug 2023 17:39:25 +0800 Subject: [PATCH 1/4] dockerfile fallback debian11,fix azure cognitiveservices speech error Python 3.10-slim based Debian 12, using Azure TextToVoice may result in an error. the Speech SDK does not currently support OpenSSL 3.0, which is the default version in Ubuntu 22.04 and Debian 12 --- docker/Dockerfile.latest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/Dockerfile.latest b/docker/Dockerfile.latest index 59e9b60..515ad3f 100644 --- a/docker/Dockerfile.latest +++ b/docker/Dockerfile.latest @@ -1,4 +1,4 @@ -FROM python:3.10-slim +FROM python:3.10-slim-bullseye LABEL maintainer="foo@bar.com" ARG TZ='Asia/Shanghai' @@ -32,4 +32,4 @@ RUN chmod +x /entrypoint.sh \ USER noroot -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file +ENTRYPOINT ["/entrypoint.sh"] From 241fad55248d5c64cdf292c1b5336e224853b9ce Mon Sep 17 00:00:00 2001 From: eks Date: Fri, 11 Aug 2023 13:49:47 +0800 Subject: [PATCH 2/4] Update config-template.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 把温度值默认放进config.json --- config-template.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config-template.json b/config-template.json index ae930de..0c14ff4 100644 --- a/config-template.json +++ b/config-template.json @@ -29,6 +29,8 @@ "conversation_max_tokens": 1000, "expires_in_seconds": 3600, "character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。", + "temperature": 0.7, + "top_p": 1, "subscribe_msg": "感谢您的关注!\n这里是ChatGPT,可以自由对话。\n支持语音对话。\n支持图片输入。\n支持图片输出,画字开头的消息将按要求创作图片。\n支持tool、角色扮演和文字冒险等丰富的插件。\n输入{trigger_prefix}#help 查看详细指令。", "use_linkai": false, "linkai_api_key": "", From 1cff2521f422ec3bee1a8bdb0b64094e27b3e481 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Tue, 22 Aug 2023 11:09:01 +0800 Subject: [PATCH 3/4] fix: add web.py and linkai base url --- bot/linkai/link_ai_bot.py | 4 ++-- config.py | 3 ++- plugins/linkai/midjourney.py | 3 +-- requirements.txt | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bot/linkai/link_ai_bot.py b/bot/linkai/link_ai_bot.py index d90bcb0..c5aed0f 100644 --- a/bot/linkai/link_ai_bot.py +++ b/bot/linkai/link_ai_bot.py @@ -22,7 +22,6 @@ class LinkAIBot(Bot, OpenAIImage): def __init__(self): super().__init__() - self.base_url = "https://api.link-ai.chat/v1" self.sessions = SessionManager(ChatGPTSession, model=conf().get("model") or "gpt-3.5-turbo") def reply(self, query, context: Context = None) -> Reply: @@ -83,7 +82,8 @@ class LinkAIBot(Bot, OpenAIImage): headers = {"Authorization": "Bearer " + linkai_api_key} # do http request - res = requests.post(url=self.base_url + "/chat/completions", json=body, headers=headers, + base_url = conf().get("linkai_api_base", "https://api.link-ai.chat") + res = requests.post(url=base_url + "/v1/chat/completions", json=body, headers=headers, timeout=conf().get("request_timeout", 180)) if res.status_code == 200: # execute success diff --git a/config.py b/config.py index fb5b407..373dd42 100644 --- a/config.py +++ b/config.py @@ -112,7 +112,8 @@ available_setting = { # 知识库平台配置 "use_linkai": False, "linkai_api_key": "", - "linkai_app_code": "" + "linkai_app_code": "", + "linkai_api_base": "https://api.link-ai.chat" # linkAI服务地址,若国内无法访问或延迟较高可改为 https://api.link-ai.tech } diff --git a/plugins/linkai/midjourney.py b/plugins/linkai/midjourney.py index c6c6cfa..d7d0634 100644 --- a/plugins/linkai/midjourney.py +++ b/plugins/linkai/midjourney.py @@ -68,8 +68,7 @@ class MJTask: # midjourney bot class MJBot: def __init__(self, config): - self.base_url = "https://api.link-ai.chat/v1/img/midjourney" - + self.base_url = conf().get("linkai_api_base", "https://api.link-ai.chat") + "/v1/img/midjourney" self.headers = {"Authorization": "Bearer " + conf().get("linkai_api_key")} self.config = config self.tasks = {} diff --git a/requirements.txt b/requirements.txt index 7fec2c6..0863125 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ requests>=2.28.2 chardet>=5.1.0 Pillow pre-commit +web.py From 2dcd026e9fd99be685e57d8533a82817d3621fd6 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Fri, 25 Aug 2023 11:19:00 +0800 Subject: [PATCH 4/4] logs: add baidu reply log --- bot/baidu/baidu_wenxin.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bot/baidu/baidu_wenxin.py b/bot/baidu/baidu_wenxin.py index 589e249..315459e 100644 --- a/bot/baidu/baidu_wenxin.py +++ b/bot/baidu/baidu_wenxin.py @@ -77,6 +77,7 @@ class BaiduWenxinBot(Bot): payload = {'messages': session.messages} response = requests.request("POST", url, headers=headers, data=json.dumps(payload)) response_text = json.loads(response.text) + logger.info(f"[BAIDU] response text={response_text}") res_content = response_text["result"] total_tokens = response_text["usage"]["total_tokens"] completion_tokens = response_text["usage"]["completion_tokens"]