Skip to content

Commit 7e87a8f

Browse files
author
Mai Hoàng
committed
Improve program webpage prompt visualizer
1 parent a891789 commit 7e87a8f

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

scripts/templates/program_page.html

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,36 @@ <h2>Code:</h2>
2727
<pre>{{ program_data.code }}</pre>
2828
<h2>Prompts:</h2>
2929
<ul>
30+
{#-- recursive “display” macro --#}
31+
{% macro display(val) %}
32+
{% if val is mapping %}
33+
<ul>
34+
{% for k, v in val.items() %}
35+
<li>
36+
<strong>{{ k|e }}:</strong>
37+
{{ display(v) }}
38+
</li>
39+
{% endfor %}
40+
</ul>
41+
{% elif val is sequence and not val is string %}
42+
<ul>
43+
{% for item in val %}
44+
<li>{{ display(item) }}</li>
45+
{% endfor %}
46+
</ul>
47+
{% else %}
48+
<pre>{{ val|e }}</pre>
49+
{% endif %}
50+
{% endmacro %}
51+
{#-- loop over every prompts --#}
52+
<div class="prompts">
3053
{% for key, value in program_data.prompts.items() %}
31-
<li><strong>{{ key }}:</strong> <pre style="white-space: pre-wrap; word-break: break-word;">{{ value }}</pre></li>
54+
<section>
55+
<h3>{{ key|title }}</h3>
56+
{{ display(value) }}
57+
</section>
3258
{% endfor %}
59+
</div>
3360
</ul>
3461
{% if artifacts_json %}
3562
<h2>Artifacts:</h2>

0 commit comments

Comments
 (0)