Skip to content

Commit

Permalink
🐛 Bug: Fix the bug causing image file upload failure.
Browse files Browse the repository at this point in the history
💻 Code: Upgrade ModelMerge version to 0.6.11
  • Loading branch information
yym68686 committed Jun 17, 2024
1 parent b91ba4b commit eb656da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ async def command_bot(update, context, language=None, prompt=translator_prompt,

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)
Expand Down Expand Up @@ -475,6 +477,8 @@ async def handle_file(update, context):

if file_url == None and image_url:
file_url = image_url
if image_url == None and file_url:
image_url = file_url
message = Document_extract(file_url, image_url, engine)

robot.add_to_conversation(message, role, convo_id)
Expand Down Expand Up @@ -601,10 +605,10 @@ async def process_update(update):
application.add_handler(CommandHandler("zh2en", lambda update, context: command_bot(update, context, "english", robot=config.translate_bot)))
application.add_handler(CommandHandler("info", info))
application.add_handler(InlineQueryHandler(inlinequery))
application.add_handler(MessageHandler(filters.Document.PDF | filters.Document.TXT | filters.Document.DOC | filters.Document.FileExtension("jpg") | filters.Document.FileExtension("jpeg"), handle_file))
# application.add_handler(MessageHandler(~filters.CAPTION & , handle_file))
application.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND, lambda update, context: command_bot(update, context, prompt=None, has_command=False), block = False))
application.add_handler(MessageHandler(filters.CAPTION & filters.PHOTO & ~filters.COMMAND, lambda update, context: command_bot(update, context, prompt=None, has_command=False)))
application.add_handler(MessageHandler(~filters.CAPTION & filters.PHOTO & ~filters.COMMAND, handle_file))
application.add_handler(MessageHandler(filters.CAPTION & ((filters.PHOTO & ~filters.COMMAND) | (filters.Document.FileExtension("jpg") | filters.Document.FileExtension("jpeg") | filters.Document.FileExtension("png"))), lambda update, context: command_bot(update, context, prompt=None, has_command=False)))
application.add_handler(MessageHandler(~filters.CAPTION & ((filters.PHOTO & ~filters.COMMAND) | (filters.Document.PDF | filters.Document.TXT | filters.Document.DOC | filters.Document.FileExtension("jpg") | filters.Document.FileExtension("jpeg"))), handle_file))
application.add_handler(MessageHandler(filters.COMMAND, unknown))
application.add_error_handler(error)

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--index-url https://pypi.python.org/simple/
python-dotenv
md2tgmd==0.2.2
ModelMerge==0.6.10
ModelMerge==0.6.11
python-telegram-bot[webhooks,rate-limiter]==21.0.1

0 comments on commit eb656da

Please sign in to comment.