GPT fixes

Fix

Test
This commit is contained in:
2023-09-07 10:37:01 +02:00
committed by migatu
parent 5e3d90c038
commit 1fd5b8cfac
5 changed files with 36 additions and 34 deletions
+18 -16
View File
@@ -12,6 +12,7 @@ import io
import json
import logging
import netrc
# TODO: Dopisz do historii komend wyslanej jako definicje to co jest w jsonie
# *=========================================== Standard Library Imports
import os
@@ -72,7 +73,6 @@ MUZYKA_MOJEGO_LUDU_HISTORIA = 1500
MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE = 15
MUZYKA_MOJEGO_LUDU_PLAJLISTA = 30
# *=========================================== Platform Specific Predefines
if platform in ("linux", "linux2"):
@@ -80,6 +80,7 @@ if platform in ("linux", "linux2"):
if "microsoft-standard" in uname().release:
LOGFILE = "/home/mtuszowski/conjurer/discord.log"
MEMORY_FIVE_SIARA = "/home/mtuszowski/conjurer/pamiec.json"
SYSTEM_GPT_SETTINGS = "/home/mtuszowski/conjurer/system_gpt_settings.json"
MEMORY_FIVE_MUZYKA = "/home/mtuszowski/conjurer/pamiec_muzyki.json"
MUSIC_FOLDER = "/mnt/g/Muzyka/"
SETTINGS_FILE = "/home/mtuszowski/conjurer/settings.json"
@@ -93,6 +94,7 @@ if platform in ("linux", "linux2"):
else:
LOGFILE = "/home/pi/Conjurer/discord.log"
MEMORY_FIVE_SIARA = "/home/pi/Conjurer/pamiec.json"
SYSTEM_GPT_SETTINGS = "/home/pi/Conjurer/conjurer/system_gpt_settings.json"
MEMORY_FIVE_MUZYKA = "/home/pi/Conjurer/pamiec_muzyki.json"
MUSIC_FOLDER = "/home/pi/RetroPie/mp3/"
SETTINGS_FILE = "/home/pi/Conjurer/settings.json"
@@ -107,6 +109,7 @@ if platform in ("linux", "linux2"):
elif platform == "win32":
LOGFILE = "discord.log"
MEMORY_FIVE_SIARA = "pamiec.json"
SYSTEM_GPT_SETTINGS = "system_gpt_settings.json"
MEMORY_FIVE_MUZYKA = "pamiec_muzyki.json"
MUSIC_FOLDER = "G:\\Muzyka\\"
SETTINGS_FILE = "settings.json"
@@ -167,6 +170,10 @@ for mp3_item in Path.glob(Path(MUSIC_FOLDER), "**/*.mp3"):
if platform == "win32":
temp_music_file = temp_music_file.replace("/", "\\")
music_file_list.append(temp_music_file)
with open(SYSTEM_GPT_SETTINGS, "r+", encoding=ENCODING) as temp_settings_file:
# First we load existing data into a dict.
GPT_SETTINGS = json.load(temp_settings_file)
with open(MEMORY_FIVE_SIARA, "r+", encoding=ENCODING) as temp_memory_file:
# First we load existing data into a dict.
MESSAGE_TABLE = json.load(temp_memory_file)
@@ -572,27 +579,22 @@ async def handle_response(prompt, vykidailo, bartender, history, username, music
# convert back to json.
json.dump(file_data, file_memory, indent=4)
history = []
# * append bo pierwszy index
# * extend bo 20 ostatnich
if music:
history.append(message_table_muzyka[0])
history.extend(message_table_muzyka[-25:])
response = await openai.ChatCompletion.acreate(
model="gpt-4-32k", messages=history
)
history.append(GPT_SETTINGS[0])
for (slowo, reakcja) in word_reactions.items():
temp = {"role : system", "content : Kiedy słyszysz " + slowo + " to reagujesz lub dzieje się to " + reakcja}
else:
history.append(MESSAGE_TABLE[0])
history.extend(MESSAGE_TABLE[-25:])
if music:
history.extend(message_table_muzyka)
response = await openai.ChatCompletion.acreate(
model="gpt-3.5-turbo-16k", messages=history
)
else:
history.extend(MESSAGE_TABLE)
response = await openai.ChatCompletion.acreate(
model="gpt-4-32k", messages=history
)
logger.info("Historia wysłana:")
logger.debug(history)
response = await openai.ChatCompletion.acreate(
model="gpt-3.5-turbo", messages=history
)
await asyncio.sleep(10)
result = ""
logger.debug("Odpowiedzi")