Add preset prompt buttons in footer
Browse files
app.py
CHANGED
|
@@ -33,6 +33,7 @@ with col1:
|
|
| 33 |
prompt = st.text_area(
|
| 34 |
"Describe what you want the code to do:",
|
| 35 |
height=150,
|
|
|
|
| 36 |
placeholder="e.g., Plot a bar chart of the top 5 most frequent words in this text.",
|
| 37 |
)
|
| 38 |
|
|
@@ -84,3 +85,22 @@ if "result" in st.session_state:
|
|
| 84 |
st.caption("No trace data available.")
|
| 85 |
else:
|
| 86 |
st.caption("Run a prompt to see the execution trace.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
prompt = st.text_area(
|
| 34 |
"Describe what you want the code to do:",
|
| 35 |
height=150,
|
| 36 |
+
key="prompt_input",
|
| 37 |
placeholder="e.g., Plot a bar chart of the top 5 most frequent words in this text.",
|
| 38 |
)
|
| 39 |
|
|
|
|
| 85 |
st.caption("No trace data available.")
|
| 86 |
else:
|
| 87 |
st.caption("Run a prompt to see the execution trace.")
|
| 88 |
+
|
| 89 |
+
st.divider()
|
| 90 |
+
|
| 91 |
+
st.subheader("Try a Sample Prompt")
|
| 92 |
+
|
| 93 |
+
PRESET_PROMPTS = [
|
| 94 |
+
"Use asyncio and aiohttp to fetch JSON from https://jsonplaceholder.typicode.com/todos/1 and print the title field.",
|
| 95 |
+
"Generate a NumPy array of shape (5, 5) filled with random integers between 0 and 100, then compute the row-wise means.",
|
| 96 |
+
"Plot a sine wave and a cosine wave on the same chart using matplotlib, add a legend, and save it to /tmp/waves.png.",
|
| 97 |
+
]
|
| 98 |
+
|
| 99 |
+
cols = st.columns(len(PRESET_PROMPTS))
|
| 100 |
+
for i, (col, p) in enumerate(zip(cols, PRESET_PROMPTS)):
|
| 101 |
+
with col:
|
| 102 |
+
if st.button(f"Prompt {i + 1}", use_container_width=True, type="secondary"):
|
| 103 |
+
st.session_state.prompt_input = p
|
| 104 |
+
st.rerun()
|
| 105 |
+
if st.session_state.get("prompt_input") == p:
|
| 106 |
+
st.caption("selected")
|