|
|
@ -1267,16 +1267,6 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
|
|
|
|
|
|
|
|
|
|
|
|
self.conversation_threads[thread.id] = Thread(thread.id)
|
|
|
|
self.conversation_threads[thread.id] = Thread(thread.id)
|
|
|
|
|
|
|
|
|
|
|
|
# Append the starter text for gpt3 to the user's history so it gets concatenated with the prompt later
|
|
|
|
|
|
|
|
if minimal or opener_file:
|
|
|
|
|
|
|
|
self.conversation_threads[thread.id].history.append(
|
|
|
|
|
|
|
|
self.CONVERSATION_STARTER_TEXT_MINIMAL
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
elif not minimal:
|
|
|
|
|
|
|
|
self.conversation_threads[thread.id].history.append(
|
|
|
|
|
|
|
|
self.CONVERSATION_STARTER_TEXT
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not opener and not opener_file:
|
|
|
|
if not opener and not opener_file:
|
|
|
|
user_id_normalized = user.id
|
|
|
|
user_id_normalized = user.id
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -1284,14 +1274,18 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
|
|
|
|
if not opener_file:
|
|
|
|
if not opener_file:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if opener_file.endswith((".txt", ".json")):
|
|
|
|
if not opener_file.endswith((".txt", ".json")):
|
|
|
|
|
|
|
|
opener_file = None
|
|
|
|
|
|
|
|
else:
|
|
|
|
# Load the file and read it into opener
|
|
|
|
# Load the file and read it into opener
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
opener_file = re.sub(".+(?=[\\//])", "", opener_file) # remove paths from the opener file
|
|
|
|
opener_file = EnvService.find_shared_file(
|
|
|
|
opener_file = EnvService.find_shared_file(
|
|
|
|
f"openers{separator}{opener_file}"
|
|
|
|
f"openers{separator}{opener_file}"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
opener_file = await self.load_file(opener_file, ctx)
|
|
|
|
opener_file = await self.load_file(opener_file, ctx)
|
|
|
|
try:
|
|
|
|
try: # Try opening as json, if it fails it'll do it as a str
|
|
|
|
opener_file = json.loads(opener_file) # Try opening as json, if it fails it'll do it as a str
|
|
|
|
opener_file = json.loads(opener_file)
|
|
|
|
temperature=None if not opener_file["temperature"] else opener_file["temperature"]
|
|
|
|
temperature=None if not opener_file["temperature"] else opener_file["temperature"]
|
|
|
|
top_p=None if not opener_file["top_p"] else opener_file["top_p"]
|
|
|
|
top_p=None if not opener_file["top_p"] else opener_file["top_p"]
|
|
|
|
frequency_penalty=None if not opener_file["frequency_penalty"] else opener_file["frequency_penalty"]
|
|
|
|
frequency_penalty=None if not opener_file["frequency_penalty"] else opener_file["frequency_penalty"]
|
|
|
@ -1301,11 +1295,24 @@ class GPT3ComCon(discord.Cog, name="GPT3ComCon"):
|
|
|
|
opener = opener_file["text"]
|
|
|
|
opener = opener_file["text"]
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
opener = opener_file["text"] + opener
|
|
|
|
opener = opener_file["text"] + opener
|
|
|
|
except:
|
|
|
|
except: # Parse as just regular text
|
|
|
|
if not opener: # if we only use opener_file then only pass on opener_file for the opening prompt
|
|
|
|
if not opener:
|
|
|
|
opener = opener_file
|
|
|
|
opener = opener_file
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
opener = opener_file + opener
|
|
|
|
opener = opener_file + opener
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
opener_file = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Append the starter text for gpt3 to the user's history so it gets concatenated with the prompt later
|
|
|
|
|
|
|
|
if minimal or opener_file:
|
|
|
|
|
|
|
|
self.conversation_threads[thread.id].history.append(
|
|
|
|
|
|
|
|
self.CONVERSATION_STARTER_TEXT_MINIMAL
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
elif not minimal:
|
|
|
|
|
|
|
|
self.conversation_threads[thread.id].history.append(
|
|
|
|
|
|
|
|
self.CONVERSATION_STARTER_TEXT
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Set user as owner before sending anything that can error and leave the thread unowned
|
|
|
|
# Set user as owner before sending anything that can error and leave the thread unowned
|
|
|
|
self.conversation_thread_owners[user_id_normalized] = thread.id
|
|
|
|
self.conversation_thread_owners[user_id_normalized] = thread.id
|
|
|
|