From 523ef6db757db60776e0e33fabcb7cd54a341294 Mon Sep 17 00:00:00 2001 From: phixxy Date: Tue, 19 Mar 2024 23:05:30 -0700 Subject: [PATCH] allow looker to view attached files --- cogs/chatgpt.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cogs/chatgpt.py b/cogs/chatgpt.py index 4924c77..893ff26 100644 --- a/cogs/chatgpt.py +++ b/cogs/chatgpt.py @@ -393,12 +393,16 @@ class ChatGPT(commands.Cog): @commands.command( description="Image GPT4", - help="Ask GPT4 a question about an image. Usage: !question_gpt4 (link) (question)", + help="Ask GPT4 a question about an image. Usage: !looker (link) (question)", brief="Get an answer" ) async def looker(self, ctx): - image_link = ctx.message.content.split(" ", maxsplit=2)[1] - question = ctx.message.content.split(" ", maxsplit=2)[2] + if len(ctx.message.attachments) > 0: + image_link = ctx.message.attachments[0].url + question = ctx.message.content + else: + image_link = ctx.message.content.split(" ", maxsplit=2)[1] + question = ctx.message.content.split(" ", maxsplit=2)[2] data = { "model": "gpt-4-vision-preview",