Skip to content

Commit

Permalink
fix show_templates GH actions for blank outputs (conditional templates)
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorSanh committed Jun 8, 2021
1 parent af311d6 commit 9eac554
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions promptsource/show_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@
print(template.jinja)
print()

for example_index in range(10):
example = dataset[example_index]
print_counter = 0
for example in dataset:
print("\t--------")
print("\tExample ", example)
print("\t--------")
xp, yp = template.apply(example)
output = template.apply(example)
if output == [""]:
print("\t Blank result")
continue

xp, yp = output
print()
print("\tPrompt | X")
for line in textwrap.wrap(xp, width=width, replace_whitespace=False):
Expand All @@ -53,3 +58,7 @@
print("\tY")
for line in textwrap.wrap(yp, width=width, replace_whitespace=False):
print("\t", line.replace("\n", "\n\t"))

print_counter += 1
if print_counter >= 10:
break

0 comments on commit 9eac554

Please sign in to comment.