mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-17 15:22:10 +00:00
Fixes + upgrade GPT model
Fix 2.0 Fix Nope
This commit is contained in:
@@ -278,22 +278,25 @@ async def on_message(message):
|
|||||||
if kondziu_mentioned or "conjurer:" in message.content:
|
if kondziu_mentioned or "conjurer:" in message.content:
|
||||||
async with channel.typing():
|
async with channel.typing():
|
||||||
logger.debug("Procedura chatu")
|
logger.debug("Procedura chatu")
|
||||||
|
|
||||||
message.content = message.content.replace("conjurer: ", "")
|
message.content = message.content.replace("conjurer: ", "")
|
||||||
|
|
||||||
prompt = message.content
|
|
||||||
|
|
||||||
if message.author.nick:
|
if message.author.nick:
|
||||||
username = message.author.nick
|
username = message.author.nick
|
||||||
else:
|
else:
|
||||||
username = message.author.name
|
username = message.author.name
|
||||||
vykidailo = False
|
vykidailo = False
|
||||||
bartender = False
|
bartender = False
|
||||||
|
if kondziu_mentioned:
|
||||||
|
prompt = message.clean_content
|
||||||
|
else:
|
||||||
|
prompt = message.content
|
||||||
for role in message.author.roles:
|
for role in message.author.roles:
|
||||||
if role.name == "Vykidailo":
|
if role.name == "Vykidailo":
|
||||||
vykidailo = True
|
vykidailo = True
|
||||||
if role.name == "Bartender":
|
if role.name == "Bartender":
|
||||||
bartender = True
|
bartender = True
|
||||||
global MESSAGE_TABLE # pylint: disable=global-statement
|
global MESSAGE_TABLE # pylint: disable=global-statement
|
||||||
|
|
||||||
result, MESSAGE_TABLE = await handle_response(
|
result, MESSAGE_TABLE = await handle_response(
|
||||||
prompt, vykidailo, bartender, MESSAGE_TABLE, username, False
|
prompt, vykidailo, bartender, MESSAGE_TABLE, username, False
|
||||||
)
|
)
|
||||||
@@ -526,6 +529,7 @@ async def check():
|
|||||||
|
|
||||||
|
|
||||||
# trunk-ignore(pylint/R0913)
|
# trunk-ignore(pylint/R0913)
|
||||||
|
# trunk-ignore(pylint/R0915)
|
||||||
async def handle_response(prompt, vykidailo, bartender, history, username, music):
|
async def handle_response(prompt, vykidailo, bartender, history, username, music):
|
||||||
"""
|
"""
|
||||||
Handle responses by appending them to a history, use OpenAI to
|
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
|
# * extend bo 20 ostatnich
|
||||||
if music:
|
if music:
|
||||||
history.append(message_table_muzyka[0])
|
history.append(message_table_muzyka[0])
|
||||||
history.extend(message_table_muzyka[-15:])
|
history.extend(message_table_muzyka[-25:])
|
||||||
response = await openai.ChatCompletion.acreate(
|
response = await openai.ChatCompletion.acreate(
|
||||||
model="gpt-4-32k", messages=history
|
model="gpt-4-32k", messages=history
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
history.append(MESSAGE_TABLE[0])
|
history.append(MESSAGE_TABLE[0])
|
||||||
history.extend(MESSAGE_TABLE[-15:])
|
history.extend(MESSAGE_TABLE[-25:])
|
||||||
response = await openai.ChatCompletion.acreate(
|
response = await openai.ChatCompletion.acreate(
|
||||||
model="gpt-3.5-turbo-16k", messages=history
|
model="gpt-3.5-turbo-16k", messages=history
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user