From 916762cc8c4a5b4696bbe1a3df164b8712e6c059 Mon Sep 17 00:00:00 2001 From: stx116 <63991243+stx116@users.noreply.github.com> Date: Thu, 1 Feb 2024 15:18:56 +0800 Subject: [PATCH 01/13] Update xunfei_spark_bot.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新讯飞大语言模型到3.5版本 --- bot/xunfei/xunfei_spark_bot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/xunfei/xunfei_spark_bot.py b/bot/xunfei/xunfei_spark_bot.py index 395d81e..cd9e63a 100644 --- a/bot/xunfei/xunfei_spark_bot.py +++ b/bot/xunfei/xunfei_spark_bot.py @@ -46,8 +46,8 @@ class XunFeiBot(Bot): 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" + # v3.5版本为: "ws://spark-api.xf-yun.com/v3.5/chat" + self.spark_url = "ws://spark-api.xf-yun.com/v3.5/chat" self.host = urlparse(self.spark_url).netloc self.path = urlparse(self.spark_url).path # 和wenxin使用相同的session机制 From a25d7ea65b4ea4fb4a32d48a5ce03883a6ffd941 Mon Sep 17 00:00:00 2001 From: xiexin12138 Date: Tue, 20 Feb 2024 16:40:00 +0800 Subject: [PATCH 02/13] =?UTF-8?q?add=20feature=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=99=BA=E8=B0=B1=20AI=20=E7=9A=84=E5=91=BD=E4=BB=A4=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=EF=BC=8C=E4=BD=BF=E5=85=B6=E6=94=AF=E6=8C=81=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E4=BC=9A=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/godcmd/godcmd.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/godcmd/godcmd.py b/plugins/godcmd/godcmd.py index a965a68..c36dd91 100644 --- a/plugins/godcmd/godcmd.py +++ b/plugins/godcmd/godcmd.py @@ -313,7 +313,7 @@ class Godcmd(Plugin): except Exception as e: ok, result = False, "你没有设置私有GPT模型" elif cmd == "reset": - if bottype in [const.OPEN_AI, const.CHATGPT, const.CHATGPTONAZURE, const.LINKAI, const.BAIDU, const.XUNFEI, const.QWEN, const.GEMINI]: + if bottype in [const.OPEN_AI, const.CHATGPT, const.CHATGPTONAZURE, const.LINKAI, const.BAIDU, const.XUNFEI, const.QWEN, const.GEMINI, const.ZHIPU_AI]: bot.sessions.clear_session(session_id) if Bridge().chat_bots.get(bottype): Bridge().chat_bots.get(bottype).sessions.clear_session(session_id) @@ -339,7 +339,7 @@ class Godcmd(Plugin): ok, result = True, "配置已重载" elif cmd == "resetall": if bottype in [const.OPEN_AI, const.CHATGPT, const.CHATGPTONAZURE, const.LINKAI, - const.BAIDU, const.XUNFEI, const.QWEN, const.GEMINI]: + const.BAIDU, const.XUNFEI, const.QWEN, const.GEMINI, const.ZHIPU_AI]: channel.cancel_all_session() bot.sessions.clear_all_session() ok, result = True, "重置所有会话成功" From 64ae3d1e2184bf734f8d31317c04783f40e50996 Mon Sep 17 00:00:00 2001 From: Zhuoheng Lee Date: Wed, 21 Feb 2024 14:14:19 +0800 Subject: [PATCH 03/13] Update xunfei_spark_bot.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 讯飞接口升级到v3.5版本,同时升级到wss协议,避免请求时出现11200错误码的问题 --- bot/xunfei/xunfei_spark_bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/xunfei/xunfei_spark_bot.py b/bot/xunfei/xunfei_spark_bot.py index 395d81e..b9e46ba 100644 --- a/bot/xunfei/xunfei_spark_bot.py +++ b/bot/xunfei/xunfei_spark_bot.py @@ -47,7 +47,8 @@ class XunFeiBot(Bot): # 默认使用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" + # 升级到v3.5版本,同时升级到wss协议,避免请求时出现11200错误码 + self.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机制 From 3a20461abf0446349578771aba3a1c6aba8d884a Mon Sep 17 00:00:00 2001 From: Lecter Date: Mon, 4 Mar 2024 00:14:19 +0800 Subject: [PATCH 04/13] add edge-tts --- config.py | 2 +- requirements-optional.txt | 1 + voice/edge/edge_voice.py | 50 +++++++++++++++++++++++++++++++++++++++ voice/factory.py | 4 ++++ 4 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 voice/edge/edge_voice.py diff --git a/config.py b/config.py index 154c633..acfb6a6 100644 --- a/config.py +++ b/config.py @@ -83,7 +83,7 @@ available_setting = { "voice_reply_voice": False, # 是否使用语音回复语音,需要设置对应语音合成引擎的api key "always_reply_voice": False, # 是否一直使用语音回复 "voice_to_text": "openai", # 语音识别引擎,支持openai,baidu,google,azure - "text_to_voice": "openai", # 语音合成引擎,支持openai,baidu,google,pytts(offline),azure,elevenlabs + "text_to_voice": "openai", # 语音合成引擎,支持openai,baidu,google,pytts(offline),azure,elevenlabs,edge(online) "text_to_voice_model": "tts-1", "tts_voice_id": "alloy", # baidu 语音api配置, 使用百度语音识别和语音合成时需要 diff --git a/requirements-optional.txt b/requirements-optional.txt index 74f1780..abb8a4e 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -7,6 +7,7 @@ gTTS>=2.3.1 # google text to speech pyttsx3>=2.90 # pytsx text to speech baidu_aip>=4.16.10 # baidu voice azure-cognitiveservices-speech # azure voice +edge-tts # edge-tts numpy<=1.24.2 langid # language detect diff --git a/voice/edge/edge_voice.py b/voice/edge/edge_voice.py new file mode 100644 index 0000000..7bb8b2e --- /dev/null +++ b/voice/edge/edge_voice.py @@ -0,0 +1,50 @@ +import time + +import edge_tts +import asyncio + +from bridge.reply import Reply, ReplyType +from common.log import logger +from common.tmp_dir import TmpDir +from voice.voice import Voice + + +class EdgeVoice(Voice): + + def __init__(self): + ''' + # 普通话 + zh-CN-XiaoxiaoNeural + zh-CN-XiaoyiNeural + zh-CN-YunjianNeural + zh-CN-YunxiNeural + zh-CN-YunxiaNeural + zh-CN-YunyangNeural + # 地方口音 + zh-CN-liaoning-XiaobeiNeural + zh-CN-shaanxi-XiaoniNeural + # 粤语 + zh-HK-HiuGaaiNeural + zh-HK-HiuMaanNeural + zh-HK-WanLungNeural + # 湾湾腔 + zh-TW-HsiaoChenNeural + zh-TW-HsiaoYuNeural + zh-TW-YunJheNeural + ''' + self.voice = "zh-CN-YunjianNeural" + + def voiceToText(self, voice_file): + pass + + async def gen_voice(self, text, fileName): + communicate = edge_tts.Communicate(text, self.voice) + await communicate.save(fileName) + + def textToVoice(self, text): + fileName = TmpDir().path() + "reply-" + str(int(time.time())) + "-" + str(hash(text) & 0x7FFFFFFF) + ".mp3" + + asyncio.run(self.gen_voice(text, fileName)) + + logger.info("[EdgeTTS] textToVoice text={} voice file name={}".format(text, fileName)) + return Reply(ReplyType.VOICE, fileName) diff --git a/voice/factory.py b/voice/factory.py index ed80758..bc9c9c3 100644 --- a/voice/factory.py +++ b/voice/factory.py @@ -42,4 +42,8 @@ def create_voice(voice_type): from voice.ali.ali_voice import AliVoice return AliVoice() + elif voice_type == "edge": + from voice.edge.edge_voice import EdgeVoice + + return EdgeVoice() raise RuntimeError From 805bea0d5f939241b347b8e8407298630cd37115 Mon Sep 17 00:00:00 2001 From: FB208 Date: Tue, 12 Mar 2024 10:39:51 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=86claude=20api?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E7=94=A8=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot/bot_factory.py | 5 +- bot/claudeapi/claude_api_bot.py | 125 ++++++++++++++++++++++++++++ bot/claudeapi/claude_api_session.py | 74 ++++++++++++++++ bridge/bridge.py | 7 +- common/const.py | 4 +- config-template.json | 1 + config.py | 2 + requirements.txt | 1 + 8 files changed, 215 insertions(+), 4 deletions(-) create mode 100644 bot/claudeapi/claude_api_bot.py create mode 100644 bot/claudeapi/claude_api_session.py diff --git a/bot/bot_factory.py b/bot/bot_factory.py index 2046da7..b5936c4 100644 --- a/bot/bot_factory.py +++ b/bot/bot_factory.py @@ -2,6 +2,7 @@ channel factory """ from common import const +from common.log import logger def create_bot(bot_type): @@ -43,7 +44,9 @@ def create_bot(bot_type): elif bot_type == const.CLAUDEAI: from bot.claude.claude_ai_bot import ClaudeAIBot return ClaudeAIBot() - + elif bot_type == const.CLAUDEAPI: + from bot.claudeapi.claude_api_bot import ClaudeAPIBot + return ClaudeAPIBot() elif bot_type == const.QWEN: from bot.ali.ali_qwen_bot import AliQwenBot return AliQwenBot() diff --git a/bot/claudeapi/claude_api_bot.py b/bot/claudeapi/claude_api_bot.py new file mode 100644 index 0000000..e9cf46d --- /dev/null +++ b/bot/claudeapi/claude_api_bot.py @@ -0,0 +1,125 @@ +# encoding:utf-8 + +import time + +import openai +import openai.error +import anthropic + +from bot.bot import Bot +from bot.openai.open_ai_image import OpenAIImage +from bot.claudeapi.claude_api_session import ClaudeAPISession +from bot.session_manager import SessionManager +from bridge.context import ContextType +from bridge.reply import Reply, ReplyType +from common.log import logger +from config import conf + +user_session = dict() + + +# OpenAI对话模型API (可用) +class ClaudeAPIBot(Bot, OpenAIImage): + def __init__(self): + super().__init__() + self.claudeClient = anthropic.Anthropic( + api_key=conf().get("claude_api_key") + ) + openai.api_key = conf().get("open_ai_api_key") + if conf().get("open_ai_api_base"): + openai.api_base = conf().get("open_ai_api_base") + proxy = conf().get("proxy") + if proxy: + openai.proxy = proxy + + self.sessions = SessionManager(ClaudeAPISession, model=conf().get("model") or "text-davinci-003") + + def reply(self, query, context=None): + # acquire reply content + if context and context.type: + if context.type == ContextType.TEXT: + logger.info("[CLAUDE_API] query={}".format(query)) + session_id = context["session_id"] + reply = None + if query == "#清除记忆": + self.sessions.clear_session(session_id) + reply = Reply(ReplyType.INFO, "记忆已清除") + elif query == "#清除所有": + self.sessions.clear_all_session() + reply = Reply(ReplyType.INFO, "所有人记忆已清除") + else: + session = self.sessions.session_query(query, session_id) + result = self.reply_text(session) + logger.info(result) + total_tokens, completion_tokens, reply_content = ( + result["total_tokens"], + result["completion_tokens"], + result["content"], + ) + logger.debug( + "[CLAUDE_API] new_query={}, session_id={}, reply_cont={}, completion_tokens={}".format(str(session), session_id, reply_content, completion_tokens) + ) + + if total_tokens == 0: + reply = Reply(ReplyType.ERROR, reply_content) + else: + self.sessions.session_reply(reply_content, session_id, total_tokens) + reply = Reply(ReplyType.TEXT, reply_content) + return reply + elif context.type == ContextType.IMAGE_CREATE: + ok, retstring = self.create_img(query, 0) + reply = None + if ok: + reply = Reply(ReplyType.IMAGE_URL, retstring) + else: + reply = Reply(ReplyType.ERROR, retstring) + return reply + + def reply_text(self, session: ClaudeAPISession, retry_count=0): + try: + logger.info("[CLAUDE_API] sendMessage={}".format(str(session))) + response = self.claudeClient.messages.create( + model=conf().get("model"), + max_tokens=1024, + # system=conf().get("system"), + messages=[ + {"role": "user", "content": "{}".format(str(session))} + ] + ) + # response = openai.Completion.create(prompt=str(session), **self.args) + res_content = response.content[0].text.strip().replace("<|endoftext|>", "") + total_tokens = response.usage.input_tokens+response.usage.output_tokens + completion_tokens = response.usage.output_tokens + logger.info("[CLAUDE_API] reply={}".format(res_content)) + return { + "total_tokens": total_tokens, + "completion_tokens": completion_tokens, + "content": res_content, + } + except Exception as e: + need_retry = retry_count < 2 + result = {"completion_tokens": 0, "content": "我现在有点累了,等会再来吧"} + if isinstance(e, openai.error.RateLimitError): + logger.warn("[CLAUDE_API] RateLimitError: {}".format(e)) + result["content"] = "提问太快啦,请休息一下再问我吧" + if need_retry: + time.sleep(20) + elif isinstance(e, openai.error.Timeout): + logger.warn("[CLAUDE_API] Timeout: {}".format(e)) + result["content"] = "我没有收到你的消息" + if need_retry: + time.sleep(5) + elif isinstance(e, openai.error.APIConnectionError): + logger.warn("[CLAUDE_API] APIConnectionError: {}".format(e)) + need_retry = False + result["content"] = "我连接不到你的网络" + else: + logger.warn("[CLAUDE_API] Exception: {}".format(e)) + need_retry = False + self.sessions.clear_session(session.session_id) + + if need_retry: + logger.warn("[CLAUDE_API] 第{}次重试".format(retry_count + 1)) + return self.reply_text(session, retry_count + 1) + else: + return result diff --git a/bot/claudeapi/claude_api_session.py b/bot/claudeapi/claude_api_session.py new file mode 100644 index 0000000..a5e9b54 --- /dev/null +++ b/bot/claudeapi/claude_api_session.py @@ -0,0 +1,74 @@ +from bot.session_manager import Session +from common.log import logger + + +class ClaudeAPISession(Session): + def __init__(self, session_id, system_prompt=None, model="text-davinci-003"): + super().__init__(session_id, system_prompt) + self.model = model + self.reset() + + def __str__(self): + # 构造对话模型的输入 + """ + e.g. Q: xxx + A: xxx + Q: xxx + """ + prompt = "" + for item in self.messages: + if item["role"] == "system": + prompt += item["content"] + "<|endoftext|>\n\n\n" + elif item["role"] == "user": + prompt += "Q: " + item["content"] + "\n" + elif item["role"] == "assistant": + prompt += "\n\nA: " + item["content"] + "<|endoftext|>\n" + + if len(self.messages) > 0 and self.messages[-1]["role"] == "user": + prompt += "A: " + return prompt + + def discard_exceeding(self, max_tokens, cur_tokens=None): + precise = True + + try: + cur_tokens = self.calc_tokens() + except Exception as e: + precise = False + if cur_tokens is None: + raise e + logger.debug("Exception when counting tokens precisely for query: {}".format(e)) + while cur_tokens > max_tokens: + if len(self.messages) > 1: + self.messages.pop(0) + elif len(self.messages) == 1 and self.messages[0]["role"] == "assistant": + self.messages.pop(0) + if precise: + cur_tokens = self.calc_tokens() + else: + cur_tokens = len(str(self)) + break + elif len(self.messages) == 1 and self.messages[0]["role"] == "user": + logger.warn("user question exceed max_tokens. total_tokens={}".format(cur_tokens)) + break + else: + logger.debug("max_tokens={}, total_tokens={}, len(conversation)={}".format(max_tokens, cur_tokens, len(self.messages))) + break + if precise: + cur_tokens = self.calc_tokens() + else: + cur_tokens = len(str(self)) + return cur_tokens + def calc_tokens(self): + return num_tokens_from_string(str(self), self.model) + + +# refer to https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb +def num_tokens_from_string(string: str, model: str) -> int: + """Returns the number of tokens in a text string.""" + num_tokens = len(string) + return num_tokens + + + + diff --git a/bridge/bridge.py b/bridge/bridge.py index 88e6b18..2c76844 100644 --- a/bridge/bridge.py +++ b/bridge/bridge.py @@ -18,6 +18,7 @@ class Bridge(object): "text_to_voice": conf().get("text_to_voice", "google"), "translate": conf().get("translate", "baidu"), } + # 这边取配置的模型 model_type = conf().get("model") or const.GPT35 if model_type in ["text-davinci-003"]: self.btype["chat"] = const.OPEN_AI @@ -33,6 +34,8 @@ class Bridge(object): self.btype["chat"] = const.GEMINI if model_type in [const.ZHIPU_AI]: self.btype["chat"] = const.ZHIPU_AI + if model_type in [const.CLAUDE3]: + self.btype["chat"] = const.CLAUDEAPI if conf().get("use_linkai") and conf().get("linkai_api_key"): self.btype["chat"] = const.LINKAI @@ -40,12 +43,12 @@ class Bridge(object): self.btype["voice_to_text"] = const.LINKAI if not conf().get("text_to_voice") or conf().get("text_to_voice") in ["openai", const.TTS_1, const.TTS_1_HD]: self.btype["text_to_voice"] = const.LINKAI - if model_type in ["claude"]: self.btype["chat"] = const.CLAUDEAI + self.bots = {} self.chat_bots = {} - + # 模型对应的接口 def get_bot(self, typename): if self.bots.get(typename) is None: logger.info("create bot {} for {}".format(self.btype[typename], typename)) diff --git a/common/const.py b/common/const.py index aeb9dcc..ce11398 100644 --- a/common/const.py +++ b/common/const.py @@ -6,12 +6,14 @@ XUNFEI = "xunfei" CHATGPTONAZURE = "chatGPTOnAzure" LINKAI = "linkai" CLAUDEAI = "claude" +CLAUDEAPI= "claudeAPI" QWEN = "qwen" GEMINI = "gemini" ZHIPU_AI = "glm-4" # model +CLAUDE3="claude-3-opus-20240229" GPT35 = "gpt-3.5-turbo" GPT4 = "gpt-4" GPT4_TURBO_PREVIEW = "gpt-4-0125-preview" @@ -20,7 +22,7 @@ WHISPER_1 = "whisper-1" TTS_1 = "tts-1" TTS_1_HD = "tts-1-hd" -MODEL_LIST = ["gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-4", "wenxin", "wenxin-4", "xunfei", "claude", "gpt-4-turbo", +MODEL_LIST = ["gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-4", "wenxin", "wenxin-4", "xunfei", "claude","claude-3-opus-20240229", "gpt-4-turbo", "gpt-4-turbo-preview", "gpt-4-1106-preview", GPT4_TURBO_PREVIEW, QWEN, GEMINI, ZHIPU_AI] # channel diff --git a/config-template.json b/config-template.json index bdaadde..f3b253d 100644 --- a/config-template.json +++ b/config-template.json @@ -2,6 +2,7 @@ "channel_type": "wx", "model": "", "open_ai_api_key": "YOUR API KEY", + "claude_api_key": "YOUR API KEY", "text_to_image": "dall-e-2", "voice_to_text": "openai", "text_to_voice": "openai", diff --git a/config.py b/config.py index 154c633..29a8f54 100644 --- a/config.py +++ b/config.py @@ -67,6 +67,8 @@ available_setting = { # claude 配置 "claude_api_cookie": "", "claude_uuid": "", + # claude api key + "claude_api_key":"", # 通义千问API, 获取方式查看文档 https://help.aliyun.com/document_detail/2587494.html "qwen_access_key_id": "", "qwen_access_key_secret": "", diff --git a/requirements.txt b/requirements.txt index c032e08..f49bdfa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ chardet>=5.1.0 Pillow pre-commit web.py +anthropic \ No newline at end of file From a241dc6785d7ac9725c9f97a9fefb26e0ce7c16a Mon Sep 17 00:00:00 2001 From: FB208 Date: Tue, 12 Mar 2024 13:09:55 +0800 Subject: [PATCH 06/13] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dadf801..cfd371d 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,8 @@ pip3 install -r requirements-optional.txt # config.json文件内容示例 { "open_ai_api_key": "YOUR API KEY", # 填入上面创建的 OpenAI API KEY - "model": "gpt-3.5-turbo", # 模型名称, 支持 gpt-3.5-turbo, gpt-3.5-turbo-16k, gpt-4, wenxin, xunfei + "model": "gpt-3.5-turbo", # 模型名称, 支持 gpt-3.5-turbo, gpt-3.5-turbo-16k, gpt-4, wenxin, xunfei, claude-3-opus-20240229 + "claude_api_key":"YOUR API KEY" # 如果选用claude3模型的话,配置这个key,同时如想使用生图,语音等功能,仍需配置open_ai_api_key "proxy": "", # 代理客户端的ip和端口,国内环境开启代理的需要填写该项,如 "127.0.0.1:7890" "single_chat_prefix": ["bot", "@bot"], # 私聊时文本需要包含该前缀才能触发机器人回复 "single_chat_reply_prefix": "[bot] ", # 私聊时自动回复的前缀,用于区分真人 From 943aa05eaa58dba46a0a2cccd94b1d412313adbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A1Q=E5=9B=A0?= <56462540+Meng-de-Cao@users.noreply.github.com> Date: Wed, 20 Mar 2024 21:22:15 +0800 Subject: [PATCH 07/13] Update xunfei_spark_bot.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 默认使用讯飞3.5模型 --- bot/xunfei/xunfei_spark_bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/xunfei/xunfei_spark_bot.py b/bot/xunfei/xunfei_spark_bot.py index 395d81e..9ca6b96 100644 --- a/bot/xunfei/xunfei_spark_bot.py +++ b/bot/xunfei/xunfei_spark_bot.py @@ -47,7 +47,8 @@ class XunFeiBot(Bot): # 默认使用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" + # v3.5版本为: "wss://spark-api.xf-yun.com/v3.5/chat" + self.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机制 From cac7a6228a5eaece625006e33ca1342ba02bee4b Mon Sep 17 00:00:00 2001 From: zhayujie Date: Mon, 25 Mar 2024 21:41:40 +0800 Subject: [PATCH 08/13] fix: claude api optimize --- bot/chatgpt/chat_gpt_session.py | 3 ++- bot/claudeapi/claude_api_bot.py | 25 ++++++++++++++++++------- bot/linkai/link_ai_bot.py | 14 ++++++++++---- bridge/bridge.py | 2 +- requirements-optional.txt | 2 ++ requirements.txt | 3 +-- 6 files changed, 34 insertions(+), 15 deletions(-) diff --git a/bot/chatgpt/chat_gpt_session.py b/bot/chatgpt/chat_gpt_session.py index c4b17fd..089fa4e 100644 --- a/bot/chatgpt/chat_gpt_session.py +++ b/bot/chatgpt/chat_gpt_session.py @@ -68,7 +68,8 @@ def num_tokens_from_messages(messages, model): "gpt-3.5-turbo-16k", "gpt-3.5-turbo-16k-0613", "gpt-35-turbo-16k", "gpt-4-turbo-preview", "gpt-4-1106-preview", const.GPT4_TURBO_PREVIEW, const.GPT4_VISION_PREVIEW]: return num_tokens_from_messages(messages, model="gpt-4") - + elif model.startswith("claude-3"): + return num_tokens_from_messages(messages, model="gpt-3.5-turbo") try: encoding = tiktoken.encoding_for_model(model) except KeyError: diff --git a/bot/claudeapi/claude_api_bot.py b/bot/claudeapi/claude_api_bot.py index e9cf46d..c782d3e 100644 --- a/bot/claudeapi/claude_api_bot.py +++ b/bot/claudeapi/claude_api_bot.py @@ -9,6 +9,7 @@ import anthropic from bot.bot import Bot from bot.openai.open_ai_image import OpenAIImage from bot.claudeapi.claude_api_session import ClaudeAPISession +from bot.chatgpt.chat_gpt_session import ChatGPTSession from bot.session_manager import SessionManager from bridge.context import ContextType from bridge.reply import Reply, ReplyType @@ -32,7 +33,7 @@ class ClaudeAPIBot(Bot, OpenAIImage): if proxy: openai.proxy = proxy - self.sessions = SessionManager(ClaudeAPISession, model=conf().get("model") or "text-davinci-003") + self.sessions = SessionManager(ChatGPTSession, model=conf().get("model") or "text-davinci-003") def reply(self, query, context=None): # acquire reply content @@ -75,16 +76,17 @@ class ClaudeAPIBot(Bot, OpenAIImage): reply = Reply(ReplyType.ERROR, retstring) return reply - def reply_text(self, session: ClaudeAPISession, retry_count=0): + def reply_text(self, session: ChatGPTSession, retry_count=0): try: - logger.info("[CLAUDE_API] sendMessage={}".format(str(session))) + if session.messages[0].get("role") == "system": + system = session.messages[0].get("content") + session.messages.pop(0) + actual_model = self._model_mapping(conf().get("model")) response = self.claudeClient.messages.create( - model=conf().get("model"), + model=actual_model, max_tokens=1024, # system=conf().get("system"), - messages=[ - {"role": "user", "content": "{}".format(str(session))} - ] + messages=session.messages ) # response = openai.Completion.create(prompt=str(session), **self.args) res_content = response.content[0].text.strip().replace("<|endoftext|>", "") @@ -123,3 +125,12 @@ class ClaudeAPIBot(Bot, OpenAIImage): return self.reply_text(session, retry_count + 1) else: return result + + def _model_mapping(self, model) -> str: + if model == "claude-3-opus": + return "claude-3-opus-20240229" + elif model == "claude-3-sonnet": + return "claude-3-sonnet-20240229" + elif model == "claude-3-haiku": + return "claude-3-haiku-20240307" + return model diff --git a/bot/linkai/link_ai_bot.py b/bot/linkai/link_ai_bot.py index 0df20bc..2a3e57d 100644 --- a/bot/linkai/link_ai_bot.py +++ b/bot/linkai/link_ai_bot.py @@ -130,9 +130,12 @@ class LinkAIBot(Bot): response = res.json() reply_content = response["choices"][0]["message"]["content"] total_tokens = response["usage"]["total_tokens"] - logger.info(f"[LINKAI] reply={reply_content}, total_tokens={total_tokens}") - self.sessions.session_reply(reply_content, session_id, total_tokens, query=query) - + res_code = response.get('code') + logger.info(f"[LINKAI] reply={reply_content}, total_tokens={total_tokens}, res_code={res_code}") + if res_code == 429: + logger.warn(f"[LINKAI] 用户访问超出限流配置,sender_id={body.get('sender_id')}") + else: + self.sessions.session_reply(reply_content, session_id, total_tokens, query=query) agent_suffix = self._fetch_agent_suffix(response) if agent_suffix: reply_content += agent_suffix @@ -161,7 +164,10 @@ class LinkAIBot(Bot): logger.warn(f"[LINKAI] do retry, times={retry_count}") return self._chat(query, context, retry_count + 1) - return Reply(ReplyType.TEXT, "提问太快啦,请休息一下再问我吧") + error_reply = "提问太快啦,请休息一下再问我吧" + if res.status_code == 409: + error_reply = "这个问题我还没有学会,请问我其它问题吧" + return Reply(ReplyType.TEXT, error_reply) except Exception as e: logger.exception(e) diff --git a/bridge/bridge.py b/bridge/bridge.py index 2c76844..cf62bff 100644 --- a/bridge/bridge.py +++ b/bridge/bridge.py @@ -34,7 +34,7 @@ class Bridge(object): self.btype["chat"] = const.GEMINI if model_type in [const.ZHIPU_AI]: self.btype["chat"] = const.ZHIPU_AI - if model_type in [const.CLAUDE3]: + if model_type and model_type.startswith("claude-3"): self.btype["chat"] = const.CLAUDEAPI if conf().get("use_linkai") and conf().get("linkai_api_key"): diff --git a/requirements-optional.txt b/requirements-optional.txt index abb8a4e..e076558 100644 --- a/requirements-optional.txt +++ b/requirements-optional.txt @@ -26,6 +26,8 @@ websocket-client==1.2.0 # claude bot curl_cffi +# claude API +anthropic # tongyi qwen broadscope_bailian diff --git a/requirements.txt b/requirements.txt index f49bdfa..495917b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,5 +6,4 @@ requests>=2.28.2 chardet>=5.1.0 Pillow pre-commit -web.py -anthropic \ No newline at end of file +web.py \ No newline at end of file From 23b750fc4fa0cb8a3515bd871824e511a3c7b298 Mon Sep 17 00:00:00 2001 From: "WILMAR\\dengjingren" Date: Mon, 25 Mar 2024 21:56:26 +0800 Subject: [PATCH 09/13] blackroom --- plugins/source.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/source.json b/plugins/source.json index ebacc28..b0a7811 100644 --- a/plugins/source.json +++ b/plugins/source.json @@ -19,10 +19,14 @@ "Apilot": { "url": "https://github.com/6vision/Apilot.git", "desc": "通过api直接查询早报、热榜、快递、天气等实用信息的插件" - } + }, "pictureChange": { "url": "https://github.com/Yanyutin753/pictureChange.git", "desc": "利用stable-diffusion和百度Ai进行图生图或者画图的插件" + }, + "Blackroom": { + "url": "https://github.com/dividduang/blackroom.git", + "desc": "小黑屋插件,被拉进小黑屋的人将不能使用@bot的功能的插件" } } } From 1fafd392980866ef696fd03111521075feef33d5 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Tue, 26 Mar 2024 00:06:50 +0800 Subject: [PATCH 10/13] fix: gemini session bug --- bot/chatgpt/chat_gpt_session.py | 2 +- bot/claudeapi/claude_api_bot.py | 7 +-- bot/claudeapi/claude_api_session.py | 74 ----------------------------- bot/gemini/google_gemini_bot.py | 5 +- bot/linkai/link_ai_bot.py | 1 + common/const.py | 5 +- plugins/godcmd/godcmd.py | 2 +- 7 files changed, 11 insertions(+), 85 deletions(-) delete mode 100644 bot/claudeapi/claude_api_session.py diff --git a/bot/chatgpt/chat_gpt_session.py b/bot/chatgpt/chat_gpt_session.py index 089fa4e..43b3b46 100644 --- a/bot/chatgpt/chat_gpt_session.py +++ b/bot/chatgpt/chat_gpt_session.py @@ -62,7 +62,7 @@ def num_tokens_from_messages(messages, model): import tiktoken - if model in ["gpt-3.5-turbo-0301", "gpt-35-turbo", "gpt-3.5-turbo-1106"]: + if model in ["gpt-3.5-turbo-0301", "gpt-35-turbo", "gpt-3.5-turbo-1106", "moonshot"]: return num_tokens_from_messages(messages, model="gpt-3.5-turbo") elif model in ["gpt-4-0314", "gpt-4-0613", "gpt-4-32k", "gpt-4-32k-0613", "gpt-3.5-turbo-0613", "gpt-3.5-turbo-16k", "gpt-3.5-turbo-16k-0613", "gpt-35-turbo-16k", "gpt-4-turbo-preview", diff --git a/bot/claudeapi/claude_api_bot.py b/bot/claudeapi/claude_api_bot.py index c782d3e..dfb4b06 100644 --- a/bot/claudeapi/claude_api_bot.py +++ b/bot/claudeapi/claude_api_bot.py @@ -8,8 +8,8 @@ import anthropic from bot.bot import Bot from bot.openai.open_ai_image import OpenAIImage -from bot.claudeapi.claude_api_session import ClaudeAPISession from bot.chatgpt.chat_gpt_session import ChatGPTSession +from bot.gemini.google_gemini_bot import GoogleGeminiBot from bot.session_manager import SessionManager from bridge.context import ContextType from bridge.reply import Reply, ReplyType @@ -78,15 +78,12 @@ class ClaudeAPIBot(Bot, OpenAIImage): def reply_text(self, session: ChatGPTSession, retry_count=0): try: - if session.messages[0].get("role") == "system": - system = session.messages[0].get("content") - session.messages.pop(0) actual_model = self._model_mapping(conf().get("model")) response = self.claudeClient.messages.create( model=actual_model, max_tokens=1024, # system=conf().get("system"), - messages=session.messages + messages=GoogleGeminiBot.filter_messages(session.messages) ) # response = openai.Completion.create(prompt=str(session), **self.args) res_content = response.content[0].text.strip().replace("<|endoftext|>", "") diff --git a/bot/claudeapi/claude_api_session.py b/bot/claudeapi/claude_api_session.py deleted file mode 100644 index a5e9b54..0000000 --- a/bot/claudeapi/claude_api_session.py +++ /dev/null @@ -1,74 +0,0 @@ -from bot.session_manager import Session -from common.log import logger - - -class ClaudeAPISession(Session): - def __init__(self, session_id, system_prompt=None, model="text-davinci-003"): - super().__init__(session_id, system_prompt) - self.model = model - self.reset() - - def __str__(self): - # 构造对话模型的输入 - """ - e.g. Q: xxx - A: xxx - Q: xxx - """ - prompt = "" - for item in self.messages: - if item["role"] == "system": - prompt += item["content"] + "<|endoftext|>\n\n\n" - elif item["role"] == "user": - prompt += "Q: " + item["content"] + "\n" - elif item["role"] == "assistant": - prompt += "\n\nA: " + item["content"] + "<|endoftext|>\n" - - if len(self.messages) > 0 and self.messages[-1]["role"] == "user": - prompt += "A: " - return prompt - - def discard_exceeding(self, max_tokens, cur_tokens=None): - precise = True - - try: - cur_tokens = self.calc_tokens() - except Exception as e: - precise = False - if cur_tokens is None: - raise e - logger.debug("Exception when counting tokens precisely for query: {}".format(e)) - while cur_tokens > max_tokens: - if len(self.messages) > 1: - self.messages.pop(0) - elif len(self.messages) == 1 and self.messages[0]["role"] == "assistant": - self.messages.pop(0) - if precise: - cur_tokens = self.calc_tokens() - else: - cur_tokens = len(str(self)) - break - elif len(self.messages) == 1 and self.messages[0]["role"] == "user": - logger.warn("user question exceed max_tokens. total_tokens={}".format(cur_tokens)) - break - else: - logger.debug("max_tokens={}, total_tokens={}, len(conversation)={}".format(max_tokens, cur_tokens, len(self.messages))) - break - if precise: - cur_tokens = self.calc_tokens() - else: - cur_tokens = len(str(self)) - return cur_tokens - def calc_tokens(self): - return num_tokens_from_string(str(self), self.model) - - -# refer to https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb -def num_tokens_from_string(string: str, model: str) -> int: - """Returns the number of tokens in a text string.""" - num_tokens = len(string) - return num_tokens - - - - diff --git a/bot/gemini/google_gemini_bot.py b/bot/gemini/google_gemini_bot.py index e63f1cb..6132b78 100644 --- a/bot/gemini/google_gemini_bot.py +++ b/bot/gemini/google_gemini_bot.py @@ -33,7 +33,7 @@ class GoogleGeminiBot(Bot): logger.info(f"[Gemini] query={query}") session_id = context["session_id"] session = self.sessions.session_query(query, session_id) - gemini_messages = self._convert_to_gemini_messages(self._filter_messages(session.messages)) + gemini_messages = self._convert_to_gemini_messages(self.filter_messages(session.messages)) genai.configure(api_key=self.api_key) model = genai.GenerativeModel('gemini-pro') response = model.generate_content(gemini_messages) @@ -61,7 +61,8 @@ class GoogleGeminiBot(Bot): }) return res - def _filter_messages(self, messages: list): + @staticmethod + def filter_messages(messages: list): res = [] turn = "user" if not messages: diff --git a/bot/linkai/link_ai_bot.py b/bot/linkai/link_ai_bot.py index 2a3e57d..960b788 100644 --- a/bot/linkai/link_ai_bot.py +++ b/bot/linkai/link_ai_bot.py @@ -7,6 +7,7 @@ import requests import config from bot.bot import Bot from bot.chatgpt.chat_gpt_session import ChatGPTSession +from bot.gemini.google_gemini_bot import GoogleGeminiBot from bot.session_manager import SessionManager from bridge.context import Context, ContextType from bridge.reply import Reply, ReplyType diff --git a/common/const.py b/common/const.py index ce11398..6141b7d 100644 --- a/common/const.py +++ b/common/const.py @@ -10,10 +10,11 @@ CLAUDEAPI= "claudeAPI" QWEN = "qwen" GEMINI = "gemini" ZHIPU_AI = "glm-4" +MOONSHOT = "moonshot" # model -CLAUDE3="claude-3-opus-20240229" +CLAUDE3 = "claude-3-opus-20240229" GPT35 = "gpt-3.5-turbo" GPT4 = "gpt-4" GPT4_TURBO_PREVIEW = "gpt-4-0125-preview" @@ -23,7 +24,7 @@ TTS_1 = "tts-1" TTS_1_HD = "tts-1-hd" MODEL_LIST = ["gpt-3.5-turbo", "gpt-3.5-turbo-16k", "gpt-4", "wenxin", "wenxin-4", "xunfei", "claude","claude-3-opus-20240229", "gpt-4-turbo", - "gpt-4-turbo-preview", "gpt-4-1106-preview", GPT4_TURBO_PREVIEW, QWEN, GEMINI, ZHIPU_AI] + "gpt-4-turbo-preview", "gpt-4-1106-preview", GPT4_TURBO_PREVIEW, QWEN, GEMINI, ZHIPU_AI, MOONSHOT] # channel FEISHU = "feishu" diff --git a/plugins/godcmd/godcmd.py b/plugins/godcmd/godcmd.py index c36dd91..d6383bf 100644 --- a/plugins/godcmd/godcmd.py +++ b/plugins/godcmd/godcmd.py @@ -339,7 +339,7 @@ class Godcmd(Plugin): ok, result = True, "配置已重载" elif cmd == "resetall": if bottype in [const.OPEN_AI, const.CHATGPT, const.CHATGPTONAZURE, const.LINKAI, - const.BAIDU, const.XUNFEI, const.QWEN, const.GEMINI, const.ZHIPU_AI]: + const.BAIDU, const.XUNFEI, const.QWEN, const.GEMINI, const.ZHIPU_AI, const.MOONSHOT]: channel.cancel_all_session() bot.sessions.clear_all_session() ok, result = True, "重置所有会话成功" From 21825faab01e3ce541d8ea5c5eb184de54e1520e Mon Sep 17 00:00:00 2001 From: zhayujie Date: Tue, 26 Mar 2024 16:01:05 +0800 Subject: [PATCH 11/13] docs: update README.md --- README.md | 20 +++++++------------- docs/version/old-version.md | 13 +++++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 docs/version/old-version.md diff --git a/README.md b/README.md index cfd371d..2104829 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ 最新版本支持的功能如下: - [x] **多端部署:** 有多种部署方式可选择且功能完备,目前已支持个人微信、微信公众号和、企业微信、飞书、钉钉等部署方式 -- [x] **基础对话:** 私聊及群聊的消息智能回复,支持多轮会话上下文记忆,支持 GPT-3.5, GPT-4, claude, Gemini, 文心一言, 讯飞星火, 通义千问,ChatGLM +- [x] **基础对话:** 私聊及群聊的消息智能回复,支持多轮会话上下文记忆,支持 GPT-3.5, GPT-4, Claude-3, Gemini, 文心一言, 讯飞星火, 通义千问,ChatGLM-4 - [x] **语音能力:** 可识别语音消息,通过文字或语音回复,支持 azure, baidu, google, openai(whisper/tts) 等多种语音模型 - [x] **图像能力:** 支持图片生成、图片识别、图生图(如照片修复),可选择 Dall-E-3, stable diffusion, replicate, midjourney, CogView-3, vision模型 - [x] **丰富插件:** 支持个性化插件扩展,已实现多角色切换、文字冒险、敏感词过滤、聊天记录总结、文档总结和对话、联网搜索等插件 @@ -35,7 +35,11 @@ SaaS服务、私有化部署、稳定托管接入 等多种模式。 # 更新日志 ->**2023.11.11:** [1.5.3版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.5.3) 和 [1.5.4版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.5.4),新增Google Gemini、通义千问模型 +>**2024.03.26:** [1.5.8版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.5.8) 和 [1.5.7版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.5.7),新增 GLM-4、Claude-3 模型,edge-tts 语音支持 + +>**2024.01.26:** [1.5.6版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.5.6) 和 [1.5.5版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.5.5),钉钉接入,tool插件升级,4-turbo模型更新 + +>**2023.11.11:** [1.5.3版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.5.3) 和 [1.5.4版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.5.4),新增通义千问模型、Google Gemini >**2023.11.10:** [1.5.2版本](https://github.com/zhayujie/chatgpt-on-wechat/releases/tag/1.5.2),新增飞书通道、图像识别对话、黑名单配置 @@ -49,17 +53,7 @@ SaaS服务、私有化部署、稳定托管接入 等多种模式。 >**2023.06.12:** 接入 [LinkAI](https://link-ai.tech/console) 平台,可在线创建领域知识库,并接入微信、公众号及企业微信中,打造专属客服机器人。使用参考 [接入文档](https://link-ai.tech/platform/link-app/wechat)。 ->**2023.04.26:** 支持企业微信应用号部署,兼容插件,并支持语音图片交互,私人助理理想选择,[使用文档](https://github.com/zhayujie/chatgpt-on-wechat/blob/master/channel/wechatcom/README.md)。(contributed by [@lanvent](https://github.com/lanvent) in [#944](https://github.com/zhayujie/chatgpt-on-wechat/pull/944)) - ->**2023.04.05:** 支持微信公众号部署,兼容插件,并支持语音图片交互,[使用文档](https://github.com/zhayujie/chatgpt-on-wechat/blob/master/channel/wechatmp/README.md)。(contributed by [@JS00000](https://github.com/JS00000) in [#686](https://github.com/zhayujie/chatgpt-on-wechat/pull/686)) - ->**2023.04.05:** 增加能让ChatGPT使用工具的`tool`插件,[使用文档](https://github.com/goldfishh/chatgpt-on-wechat/blob/master/plugins/tool/README.md)。工具相关issue可反馈至[chatgpt-tool-hub](https://github.com/goldfishh/chatgpt-tool-hub)。(contributed by [@goldfishh](https://github.com/goldfishh) in [#663](https://github.com/zhayujie/chatgpt-on-wechat/pull/663)) - ->**2023.03.25:** 支持插件化开发,目前已实现 多角色切换、文字冒险游戏、管理员指令、Stable Diffusion等插件,使用参考 [#578](https://github.com/zhayujie/chatgpt-on-wechat/issues/578)。(contributed by [@lanvent](https://github.com/lanvent) in [#565](https://github.com/zhayujie/chatgpt-on-wechat/pull/565)) - ->**2023.03.09:** 基于 `whisper API`(后续已接入更多的语音`API`服务) 实现对微信语音消息的解析和回复,添加配置项 `"speech_recognition":true` 即可启用,使用参考 [#415](https://github.com/zhayujie/chatgpt-on-wechat/issues/415)。(contributed by [wanggang1987](https://github.com/wanggang1987) in [#385](https://github.com/zhayujie/chatgpt-on-wechat/pull/385)) - ->**2023.02.09:** 扫码登录存在账号限制风险,请谨慎使用,参考[#58](https://github.com/AutumnWhj/ChatGPT-wechat-bot/issues/158) +更早更新日志查看: [归档日志](/docs/version/old-version.md) # 快速开始 diff --git a/docs/version/old-version.md b/docs/version/old-version.md new file mode 100644 index 0000000..ec719cd --- /dev/null +++ b/docs/version/old-version.md @@ -0,0 +1,13 @@ +## 归档更新日志 + +2023.04.26: 支持企业微信应用号部署,兼容插件,并支持语音图片交互,私人助理理想选择,使用文档。(contributed by @lanvent in #944) + +2023.04.05: 支持微信公众号部署,兼容插件,并支持语音图片交互,使用文档。(contributed by @JS00000 in #686) + +2023.04.05: 增加能让ChatGPT使用工具的tool插件,使用文档。工具相关issue可反馈至chatgpt-tool-hub。(contributed by @goldfishh in #663) + +2023.03.25: 支持插件化开发,目前已实现 多角色切换、文字冒险游戏、管理员指令、Stable Diffusion等插件,使用参考 #578。(contributed by @lanvent in #565) + +2023.03.09: 基于 whisper API(后续已接入更多的语音API服务) 实现对微信语音消息的解析和回复,添加配置项 "speech_recognition":true 即可启用,使用参考 #415。(contributed by wanggang1987 in #385) + +2023.02.09: 扫码登录存在账号限制风险,请谨慎使用,参考#58 \ No newline at end of file From 7f857d66f62fecb28312d2d8ff7a61b29715cefc Mon Sep 17 00:00:00 2001 From: zhayujie Date: Tue, 26 Mar 2024 20:12:25 +0800 Subject: [PATCH 12/13] docs: update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2104829..d7b6841 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # 简介 -> 本项目是基于大模型的智能对话机器人,支持微信、企业微信、公众号、飞书、钉钉接入,可选择GPT3.5/GPT4.0/Claude/文心一言/讯飞星火/通义千问/Gemini/LinkAI/ZhipuAI,能处理文本、语音和图片,通过插件访问操作系统和互联网等外部资源,支持基于自有知识库定制企业AI应用。 +> 本项目是基于大模型的智能对话机器人,支持企业微信、微信公众号、飞书、钉钉接入,可选择GPT3.5/GPT4.0/Claude/文心一言/讯飞星火/通义千问/Gemini/LinkAI/ZhipuAI,能处理文本、语音和图片,通过插件访问操作系统和互联网等外部资源,支持基于自有知识库定制企业AI应用。 最新版本支持的功能如下: -- [x] **多端部署:** 有多种部署方式可选择且功能完备,目前已支持个人微信、微信公众号和、企业微信、飞书、钉钉等部署方式 +- [x] **多端部署:** 有多种部署方式可选择且功能完备,目前已支持微信生态下公众号、企业微信应用、飞书、钉钉等部署方式 - [x] **基础对话:** 私聊及群聊的消息智能回复,支持多轮会话上下文记忆,支持 GPT-3.5, GPT-4, Claude-3, Gemini, 文心一言, 讯飞星火, 通义千问,ChatGLM-4 - [x] **语音能力:** 可识别语音消息,通过文字或语音回复,支持 azure, baidu, google, openai(whisper/tts) 等多种语音模型 - [x] **图像能力:** 支持图片生成、图片识别、图生图(如照片修复),可选择 Dall-E-3, stable diffusion, replicate, midjourney, CogView-3, vision模型 @@ -51,7 +51,7 @@ SaaS服务、私有化部署、稳定托管接入 等多种模式。 >**2023.08.08:** 接入百度文心一言模型,通过 [插件](https://github.com/zhayujie/chatgpt-on-wechat/tree/master/plugins/linkai) 支持 Midjourney 绘图 ->**2023.06.12:** 接入 [LinkAI](https://link-ai.tech/console) 平台,可在线创建领域知识库,并接入微信、公众号及企业微信中,打造专属客服机器人。使用参考 [接入文档](https://link-ai.tech/platform/link-app/wechat)。 +>**2023.06.12:** 接入 [LinkAI](https://link-ai.tech/console) 平台,可在线创建领域知识库,打造专属客服机器人。使用参考 [接入文档](https://link-ai.tech/platform/link-app/wechat)。 更早更新日志查看: [归档日志](/docs/version/old-version.md) @@ -187,7 +187,7 @@ pip3 install -r requirements-optional.txt python3 app.py # windows环境下该命令通常为 python app.py ``` -终端输出二维码后,使用微信进行扫码,当输出 "Start auto replying" 时表示自动回复程序已经成功运行了(注意:用于登录的微信需要在支付处已完成实名认证)。扫码登录后你的账号就成为机器人了,可以在微信手机端通过配置的关键词触发自动回复 (任意好友发送消息给你,或是自己发消息给好友),参考[#142](https://github.com/zhayujie/chatgpt-on-wechat/issues/142)。 +终端输出二维码后,使用微信进行扫码,当输出 "Start auto replying" 时表示自动回复程序已经成功运行了(注意:用于登录的微信需要在支付处已完成实名认证)。扫码登录后你的账号就成为机器人了,可以在手机端通过配置的关键词触发自动回复 (任意好友发送消息给你,或是自己发消息给好友),参考[#142](https://github.com/zhayujie/chatgpt-on-wechat/issues/142)。 ### 2.服务器部署 From c0eb433fa2174d3a31d550876830040a657b847a Mon Sep 17 00:00:00 2001 From: zhayujie Date: Wed, 27 Mar 2024 10:35:12 +0800 Subject: [PATCH 13/13] fix: remove unused import --- bot/linkai/link_ai_bot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bot/linkai/link_ai_bot.py b/bot/linkai/link_ai_bot.py index 960b788..2a3e57d 100644 --- a/bot/linkai/link_ai_bot.py +++ b/bot/linkai/link_ai_bot.py @@ -7,7 +7,6 @@ import requests import config from bot.bot import Bot from bot.chatgpt.chat_gpt_session import ChatGPTSession -from bot.gemini.google_gemini_bot import GoogleGeminiBot from bot.session_manager import SessionManager from bridge.context import Context, ContextType from bridge.reply import Reply, ReplyType