Skip to content

Commit

Permalink
Format Python code with psf/black push
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions authored and github-actions committed Jan 12, 2023
1 parent 9637ace commit 4aa20f8
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
50 changes: 31 additions & 19 deletions cogs/gpt_3_commands_and_converser.py
Original file line number Diff line number Diff line change
Expand Up @@ -805,9 +805,9 @@ async def on_message(self, message):
]
)

#set conversation overrides
# set conversation overrides
overrides = self.conversation_threads[message.channel.id].get_overrides()

await self.encapsulated_send(
message.channel.id,
primary_prompt,
Expand Down Expand Up @@ -1340,36 +1340,48 @@ async def converse(
user_id_normalized = ctx.author.id
if not opener_file:
pass
else:
else:
if not opener_file.endswith((".txt", ".json")):
opener_file = None # Just start a regular thread if the file fails to load
opener_file = (
None # Just start a regular thread if the file fails to load
)
else:
# Load the file and read it into opener
try:
opener_file = re.sub(".+(?=[\\//])", "", opener_file) # remove paths from the opener file
opener_file = re.sub(
".+(?=[\\//])", "", opener_file
) # remove paths from the opener file
opener_file = EnvService.find_shared_file(
f"openers{separator}{opener_file}"
)
opener_file = await self.load_file(opener_file, ctx)
try: # Try opening as json, if it fails it'll just pass the whole txt or json to the opener
try: # Try opening as json, if it fails it'll just pass the whole txt or json to the opener
opener_file = json.loads(opener_file)
temperature=opener_file.get("temperature", None)
top_p=opener_file.get("top_p", None)
frequency_penalty=opener_file.get("frequency_penalty", None)
presence_penalty=opener_file.get("presence_penalty", None)
self.conversation_threads[thread.id].set_overrides(temperature, top_p, frequency_penalty, presence_penalty)
if not opener: # if we only use opener_file then only pass on opener_file for the opening prompt
opener = opener_file.get('text', "error getting text")
temperature = opener_file.get("temperature", None)
top_p = opener_file.get("top_p", None)
frequency_penalty = opener_file.get(
"frequency_penalty", None
)
presence_penalty = opener_file.get("presence_penalty", None)
self.conversation_threads[thread.id].set_overrides(
temperature, top_p, frequency_penalty, presence_penalty
)
if (
not opener
): # if we only use opener_file then only pass on opener_file for the opening prompt
opener = opener_file.get("text", "error getting text")
else:
opener = opener_file.get('text', "error getting text") + opener
except: # Parse as just regular text
if not opener:
opener = (
opener_file.get("text", "error getting text")
+ opener
)
except: # Parse as just regular text
if not opener:
opener = opener_file
else:
opener = opener_file + opener
opener = opener_file + opener
except:
opener_file = None # Just start a regular thread if the file fails to load

opener_file = None # Just start a regular thread if the file fails to load

# Append the starter text for gpt3 to the user's history so it gets concatenated with the prompt later
if minimal or opener_file:
Expand Down
8 changes: 7 additions & 1 deletion models/user_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ def __init__(self, id):
self.frequency_penalty = None
self.presence_penalty = None

def set_overrides(self, temperature=None,top_p=None,frequency_penalty=None,presence_penalty=None):
def set_overrides(
self,
temperature=None,
top_p=None,
frequency_penalty=None,
presence_penalty=None,
):
self.temperature = temperature
self.top_p = top_p
self.frequency_penalty = frequency_penalty
Expand Down

0 comments on commit 4aa20f8

Please sign in to comment.