Fix compose requiring a search index existing

Fix username assignment in chatgpt conversations
Rene Teigen 1 year ago
parent c1aea39db1
commit 6782bb66dc

@ -108,6 +108,12 @@ class IndexData:
return len(os.listdir(f"{app_root_path()}/indexes/{user_id}")) > 0
except Exception:
return False
def has_search_indexes(self, user_id):
try:
return len(os.listdir(f"{app_root_path()}/indexes/{user_id}_search")) > 0
except Exception:
return False
def add_index(self, index, user_id, file_name):
self.individual_indexes.append(index)
@ -926,14 +932,15 @@ class ComposeModal(discord.ui.View):
)
]
self.indexes.extend(
[
file
for file in os.listdir(
EnvService.find_shared_file(f"indexes/{str(user_id)}_search/")
)
]
)
if index_cog.index_storage[user_id].has_search_indexes(user_id):
self.indexes.extend(
[
file
for file in os.listdir(
EnvService.find_shared_file(f"indexes/{str(user_id)}_search/")
)
]
)
print("Found the indexes, they are ", self.indexes)
# Map everything into the short to long cache

@ -850,9 +850,6 @@ class Model:
): # The response, and a boolean indicating whether or not the context limit was reached.
# Validate that all the parameters are in a good state before we send the request
# Clean up the user display name
user_displayname_clean = self.cleanse_username(user_displayname)
# Clean up the bot name
bot_name_clean = self.cleanse_username(bot_name)
@ -871,17 +868,19 @@ class Model:
)
continue
if user_displayname in message.text:
text = message.text.replace(user_displayname + ":", "")
if message.text.startswith(f"\n{bot_name}"):
text = message.text.replace(bot_name, "")
text = text.replace("<|endofstatement|>", "")
messages.append(
{"role": "user", "name": user_displayname_clean, "content": text}
{"role": "assistant", "name": bot_name_clean, "content": text}
)
else:
text = message.text.replace(bot_name, "")
username = re.search(r"(?<=\n)(.*?)(?=:)", message.text).group()
username_clean = self.cleanse_username(username)
text = message.text.replace(f"{username}:", "")
text = text.replace("<|endofstatement|>", "")
messages.append(
{"role": "assistant", "name": bot_name_clean, "content": text}
{"role": "user", "name": username_clean, "content": text}
)
print(f"Messages -> {messages}")

Loading…
Cancel
Save