Skip to content

Commit

Permalink
Fixes an issue user defined stopping strings were being overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
404-exchange committed Feb 2, 2025
1 parent dbe3461 commit 2e186b4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ async def create_text_prompt(user_input, user, character, bot, history, reply, t

prompt = character + history + reply + user + \
": " + user_input + "\n" + bot + ": "
user_stopping_strings = text_api["parameters"]["stop_sequence"]
stopping_strings = ["\n" + user + ":", user + ":", bot + ":", "You:"]

data = text_api["parameters"]
Expand All @@ -112,7 +113,7 @@ async def create_text_prompt(user_input, user, character, bot, history, reply, t
if text_api["name"] == "openai":
data.update({"stop": stopping_strings})
else:
data.update({"stop_sequence": stopping_strings})
data.update({"stop_sequence": user_stopping_strings + stopping_strings})

data_string = json.dumps(data)
return data_string
Expand All @@ -128,6 +129,7 @@ async def create_text_prompt(user_input, user, character, bot, history, reply, t
else:
prompt = character + history + reply + user + \
": " + user_input + "\n" + bot + ": "
user_stopping_strings = text_api["parameters"]["stop_sequence"]
stopping_strings = ["\n" + user + ":", user + ":", bot +
":", "You:", "@Ava", "User", "@" + user, "<|endoftext|>"]

Expand All @@ -144,7 +146,7 @@ async def create_text_prompt(user_input, user, character, bot, history, reply, t
data.update({"messages": messages})
else:
data.update({"prompt": prompt})
data.update({"stop_sequence": stopping_strings})
data.update({"stop_sequence": user_stopping_strings + stopping_strings})

data_string = json.dumps(data)
return data_string
Expand All @@ -160,6 +162,7 @@ async def create_text_prompt(user_input, user, character, bot, history, reply, t
else:
prompt = character + history + reply + user + \
": " + user_input + "\n" + bot + ": "
user_stopping_strings = text_api["parameters"]["stop_sequence"]
stopping_strings = ["\n" + user + ":", user + ":", bot +
":", "You:", "@Ava", "User", "@" + user, "<|endoftext|>"]

Expand All @@ -176,7 +179,7 @@ async def create_text_prompt(user_input, user, character, bot, history, reply, t
data.update({"messages": messages})
else:
data.update({"prompt": prompt})
data.update({"stop_sequence": stopping_strings})
data.update({"stop_sequence": user_stopping_strings + stopping_strings})

data_string = json.dumps(data)
return data_string
Expand Down

0 comments on commit 2e186b4

Please sign in to comment.