Skip to content

Commit

Permalink
Add stopping sequence parameter for ollama
Browse files Browse the repository at this point in the history
  • Loading branch information
kasnerz committed Dec 9, 2024
1 parent 9ca7b44 commit 073e991
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion factgenie/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,12 +413,20 @@ def get_optional_fields(self):
}

def postprocess_output(self, output):
if self.config.get("extra_args", {}).get("remove_suffix", ""):
extra_args = self.config.get("extra_args", {})

if extra_args.get("remove_suffix", ""):
suffix = self.config["extra_args"]["remove_suffix"]

if output.endswith(suffix):
output = output[: -len(suffix)]

if extra_args.get("stopping_sequence", False):
stopping_sequence = self.config["extra_args"]["stopping_sequence"]

if stopping_sequence in output:
output = output[: output.index(stopping_sequence)]

output = output.strip()
return output

Expand Down

0 comments on commit 073e991

Please sign in to comment.