diff --git a/bot.py b/bot.py index 9465cc2..c96322b 100644 --- a/bot.py +++ b/bot.py @@ -278,22 +278,25 @@ async def on_message(message): if kondziu_mentioned or "conjurer:" in message.content: async with channel.typing(): logger.debug("Procedura chatu") + message.content = message.content.replace("conjurer: ", "") - - prompt = message.content - if message.author.nick: username = message.author.nick else: username = message.author.name vykidailo = False bartender = False + if kondziu_mentioned: + prompt = message.clean_content + else: + prompt = message.content for role in message.author.roles: if role.name == "Vykidailo": vykidailo = True if role.name == "Bartender": bartender = True global MESSAGE_TABLE # pylint: disable=global-statement + result, MESSAGE_TABLE = await handle_response( prompt, vykidailo, bartender, MESSAGE_TABLE, username, False ) @@ -526,6 +529,7 @@ async def check(): # trunk-ignore(pylint/R0913) +# trunk-ignore(pylint/R0915) async def handle_response(prompt, vykidailo, bartender, history, username, music): """ Handle responses by appending them to a history, use OpenAI to @@ -572,14 +576,14 @@ async def handle_response(prompt, vykidailo, bartender, history, username, music # * extend bo 20 ostatnich if music: history.append(message_table_muzyka[0]) - history.extend(message_table_muzyka[-15:]) + history.extend(message_table_muzyka[-25:]) response = await openai.ChatCompletion.acreate( model="gpt-4-32k", messages=history ) else: history.append(MESSAGE_TABLE[0]) - history.extend(MESSAGE_TABLE[-15:]) + history.extend(MESSAGE_TABLE[-25:]) response = await openai.ChatCompletion.acreate( model="gpt-3.5-turbo-16k", messages=history )