From 2aed840f202b63485f66af42459c0779b7a05501 Mon Sep 17 00:00:00 2001 From: yym68686 Date: Tue, 25 Jun 2024 01:12:51 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Bug:=20Fix=20the=20bug=20in=20th?= =?UTF-8?q?e=20Claude=20API=20request=20body=20that=20is=20incorrect.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 💻 Code: Upgrade ModelMerge version to 0.7.7 --- bot.py | 23 ++++++++++------------- requirements.txt | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/bot.py b/bot.py index aabc813f..9133ab69 100644 --- a/bot.py +++ b/bot.py @@ -118,21 +118,23 @@ async def GetMesage(update_message, context): if update_message.reply_to_message: reply_to_message_text = update_message.reply_to_message.text + if update_message.document: + file = update_message.document + + file_url = await get_file_url(file, context) + + message = rawtext = CutNICK(update_message.caption, update_message) + if update_message.photo: photo = update_message.photo[-1] image_url = await get_file_url(photo, context) + if image_url == None and file_url and (file_url[-3:] == "jpg" or file_url[-3:] == "png" or file_url[-4:] == "jpeg"): + image_url = file_url if update_message.caption: message = rawtext = CutNICK(update_message.caption, update_message) - if update_message.document: - file = update_message.document - - file_url = await get_file_url(file, context) - - message = rawtext = CutNICK(update_message.caption, update_message) - return message, rawtext, image_url, chatid, messageid, reply_to_message_text, message_thread_id, convo_id, file_url async def GetMesageInfo(update, context): @@ -206,17 +208,12 @@ async def command_bot(update, context, language=None, prompt=translator_prompt, message = "\n".join(message_cache[convo_id]) message_cache[convo_id] = [] time_stamps[convo_id] = [] - - if "gpt" in engine or (config.CLAUDE_API and "claude-3" in engine): - message = [{"type": "text", "text": message}] - if image_url == None and file_url and (file_url[-3:] == "jpg" or file_url[-3:] == "png" or file_url[-4:] == "jpeg"): - image_url = file_url - message = get_image_message(image_url, message, engine) if Users.get_config(convo_id, "TYPING"): await context.bot.send_chat_action(chat_id=chatid, message_thread_id=message_thread_id, action=ChatAction.TYPING) if Users.get_config(convo_id, "TITLE"): title = f"`🤖️ {engine}`\n\n" + message = get_image_message(image_url, message, engine) await getChatGPT(update, context, title, robot, message, chatid, messageid, convo_id, message_thread_id, pass_history) else: message = await context.bot.send_message( diff --git a/requirements.txt b/requirements.txt index c7c7d399..7e500041 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ --index-url https://pypi.python.org/simple/ python-dotenv md2tgmd==0.2.3 -ModelMerge==0.7.6 +ModelMerge==0.7.7 python-telegram-bot[webhooks,rate-limiter]==21.0.1 \ No newline at end of file