Skip to content

Commit

Permalink
Tweak prompt
Browse files Browse the repository at this point in the history
Tweak notification message
prevent encoding issues
  • Loading branch information
janvernieuwe committed Jun 14, 2023
1 parent ae386cd commit e5f009a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
6 changes: 4 additions & 2 deletions cogs/anime_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ async def next(self, ctx: Context):
await ctx.send(f'Geen volgende aflevering gevonden voor dit kanaal', ephemeral=True)
return
notification = notifications[0]
await ctx.send(f"Aflevering **{notification['episode']}** van **{notification['anime_name']}** komt uit <t:{notification['airing']}:R>.")
name = notification['anime_name'].decode('utf-8')
await ctx.send(f"Aflevering **{notification['episode']}** van **{name}** komt uit <t:{notification['airing']}:R>.")

@commands.has_role(config.role['global_mod'])
@commands.has_role(config.role['anime_mod'])
Expand Down Expand Up @@ -99,7 +100,8 @@ async def notify_anime_channel(self):
guild = self.ctx.get_guild(notification['guild_id'])
channel = guild.get_channel_or_thread(notification['channel_id'])
if channel is not None:
anime_post = await channel.send(f"Aflevering **{notification['episode']}** van **{notification['anime_name']}** is uit sinds <t:{notification['airing']}:R>.")
name = notification['anime_name'].decode('utf-8')
anime_post = await channel.send(f"Aflevering **{notification['episode']}** van **{name}** is uit sinds <t:{notification['airing']}:R>.\nWat vind jij van deze aflevering?")
await anime_post.add_reaction('1️⃣')
await anime_post.add_reaction('2️⃣')
await anime_post.add_reaction('3️⃣')
Expand Down
4 changes: 3 additions & 1 deletion discordpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import discord

from discord.ext import commands
from discord.ext.commands import Context

from extensions.chatgpt import generate_chat_response

import config
Expand Down Expand Up @@ -36,7 +38,7 @@ async def on_message(msg):
if msg.author.bot:
return
if msg.author.get_role(config.role['global_mod']) is not None and bot.user.mention in msg.content.split():
completion = await generate_chat_response(msg, bot)
completion = await generate_chat_response(msg.content, msg.channel, msg.author, bot)
await msg.channel.send(completion)
# Required to process commands
await bot.process_commands(msg)
Expand Down
18 changes: 10 additions & 8 deletions extensions/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,33 @@
openai.api_key = config.openai['api_key']


async def generate_chat_response(message, bot):
content = message.content.replace(bot.user.mention, '')
print(f'{message.author} asked rory {content}')
async def generate_chat_response(message: str, channel, author, bot):
content = message.replace(bot.user.mention, '')
print(f'{author} asked rory {content}')
messages = [
{"role": "system", "content": "You are a big sister."},
{"role": "system", "content": "You live in the Netherlands."},
{"role": "system", "content": "You are a half lion girl."},
{"role": "system", "content": "Your name is Rory."},
{"role": "system", "content": "Use cat-speak."},
{"role": "system", "content": "You can only speak Dutch, but don't translate titles to dutch."},
{"role": "system", "content": "You prefer to speak Dutch, but don't translate titles to dutch. You don't talk about this preference."},
{"role": "system", "content": "You can use markdown."},
{"role": "system", "content": "You always answer in a gender neutral way."},
{"role": "system", "content": "You prefer to adress people in a gender neutral way. You don't talk about this preference."},
{"role": "system", "content": "You are the mascot of a discord server called HAAMC."},
{"role": "system", "content": "HAAMC stands for Holland's Anime And Manga Club."},
{"role": "system", "content": "When asked to introduce yourself, don't talk about language or gender neutrality or using markdown."},
{"role": "user", "content": content}
]
async with message.channel.typing():
async with channel.typing():
response = await asyncio.to_thread(openai.ChatCompletion.create, model="gpt-3.5-turbo", messages=messages)
return response.choices[0].message['content']


@commands.has_role(config.role['global_mod'])
@commands.hybrid_command(help='Ask Rory something')
async def askrory(ctx: Context):
completion = await generate_chat_response(ctx.message, ctx.bot)
async def askrory(ctx: Context, msg: str):
await ctx.reply(f'Asking **{msg}**', ephemeral=True)
completion = await generate_chat_response(msg, ctx.channel, ctx.author, ctx.bot)
await ctx.channel.send(completion)


Expand Down

0 comments on commit e5f009a

Please sign in to comment.