Skip to content

Commit

Permalink
update prompter
Browse files Browse the repository at this point in the history
  • Loading branch information
taprosoft committed Jul 31, 2023
1 parent ceee792 commit efa6df2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion utils/prompter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class PromptSelector(object):
def from_template_name(template_name: str = "", verbose: bool = False):
if "sharegpt" in template_name:
prompter = ChatPrompter(template_name, verbose)
elif template_name == "text":
prompter = None
else:
prompter = AlpacaPrompter(template_name, verbose)

Expand Down Expand Up @@ -65,7 +67,11 @@ def generate_prompt(
return res

def get_response(self, output: str) -> str:
return output.split(self.template["response_split"])[1].strip()
try:
result = output.split(self.template["response_split"])[1].strip()
except (KeyError, IndexError):
result = output
return result


class ChatPrompter(object):
Expand Down

0 comments on commit efa6df2

Please sign in to comment.