im trying to incorporate image detection into my discord bot . i want it to function how it does in the gpt-4 browser page. you give it a image and it tells you what the image is .
here is my current gpt-4 discord bot , very simply , how do incorporate the users being able to give the bot a image to describe?
import os
import discord
import openai
from discord.ext import commands
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv('DISCORD_BOT_TOKEN')
intents = discord.Intents.default()
bot = commands.Bot(command_prefix='!', intents=intents)
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
openai.api_key = OPENAI_API_KEY
@bot.event
async def on_ready():
print(f'Logged in as {bot.user.name}')
@bot.event
async def on_message(message):
#check if the message is from a user
if not message.author.bot and bot.user.mentioned_in(message):
user_message = message.content.split(' ', 1)[1]
response = 'Nothing yet!'
if user_message.startswith('!ask'):
question = message.content[5:] #remove !ask from last message content
response = openai.ChatCompletion.create(
model="gpt-4",
messages=[
{"role": "system", "content": "you are a helpful assistant."},
{"role": "user", "content": question}
],
)
await message.channel.send(response['choices'][0]['message']['content'])
await bot.process_commands(message)
def run_chat_gpt_bot():
bot.run(TOKEN)