Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -87,11 +87,22 @@ st.sidebar.write("π₯ Load GSM8K")
|
|
87 |
gsm8k_data = load_gsm8k_dataset()
|
88 |
st.sidebar.write("π GSM8K loaded:", len(gsm8k_data), "samples")
|
89 |
|
90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
92 |
if st.button("π² Pick Random Question"):
|
93 |
-
|
94 |
-
st.query_params.update(question_index=
|
|
|
95 |
|
96 |
default_prompt = "Jasper has 5 apples and eats 2 of them. How many apples does he have left?"
|
97 |
selected_question = gsm8k_data[question_index]["question"] if question_index is not None else default_prompt
|
@@ -111,6 +122,9 @@ prompt = st.text_area("Enter your math prompt:", selected_question)
|
|
111 |
|
112 |
# Generation
|
113 |
if st.button("Generate Response", key="manual"):
|
|
|
|
|
|
|
114 |
with st.sidebar:
|
115 |
with st.spinner("π Generating..."):
|
116 |
|
@@ -143,5 +157,8 @@ if st.button("Generate Response", key="manual"):
|
|
143 |
st.write(input_text)
|
144 |
st.subheader("π§ Model Output")
|
145 |
st.success(response_only)
|
146 |
-
|
147 |
-
|
|
|
|
|
|
|
|
87 |
gsm8k_data = load_gsm8k_dataset()
|
88 |
st.sidebar.write("π GSM8K loaded:", len(gsm8k_data), "samples")
|
89 |
|
90 |
+
# Check for random question index in query params
|
91 |
+
random_index = st.query_params.get("question_index")
|
92 |
+
if random_index is not None:
|
93 |
+
try:
|
94 |
+
default_index = int(random_index)
|
95 |
+
except (ValueError, TypeError):
|
96 |
+
default_index = 0
|
97 |
+
else:
|
98 |
+
default_index = 0
|
99 |
+
|
100 |
+
question_index = st.selectbox("π’ Select GSM8K question index", range(len(gsm8k_data)), index=default_index)
|
101 |
|
102 |
if st.button("π² Pick Random Question"):
|
103 |
+
new_random_index = random.randint(0, len(gsm8k_data) - 1)
|
104 |
+
st.query_params.update(question_index=new_random_index)
|
105 |
+
st.rerun() # Force app to rerun to update the selectbox
|
106 |
|
107 |
default_prompt = "Jasper has 5 apples and eats 2 of them. How many apples does he have left?"
|
108 |
selected_question = gsm8k_data[question_index]["question"] if question_index is not None else default_prompt
|
|
|
122 |
|
123 |
# Generation
|
124 |
if st.button("Generate Response", key="manual"):
|
125 |
+
# Check if the current prompt is from GSM8K dataset
|
126 |
+
is_gsm8k_question = prompt == selected_question
|
127 |
+
|
128 |
with st.sidebar:
|
129 |
with st.spinner("π Generating..."):
|
130 |
|
|
|
157 |
st.write(input_text)
|
158 |
st.subheader("π§ Model Output")
|
159 |
st.success(response_only)
|
160 |
+
|
161 |
+
# Only show correct answer if using actual GSM8K question
|
162 |
+
if is_gsm8k_question:
|
163 |
+
st.subheader("β
Correct Answer (GSM8K)")
|
164 |
+
st.info(correct_answer)
|