Spaces:
Running
Running
Updated UI, wrap most components with st.expander.
Browse files
app/streamlit_sample_generator.py
CHANGED
@@ -210,8 +210,8 @@ def package_input_data():
|
|
210 |
|
211 |
|
212 |
# Streamlit UI
|
213 |
-
st.title("Task
|
214 |
-
st.markdown("Enter
|
215 |
|
216 |
# Input column
|
217 |
input_data = st.data_editor(
|
@@ -224,88 +224,56 @@ input_data = st.data_editor(
|
|
224 |
},
|
225 |
)
|
226 |
|
227 |
-
|
228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
|
230 |
-
|
231 |
-
"
|
232 |
-
|
233 |
-
|
234 |
-
index=0
|
235 |
-
)
|
236 |
-
temperature = st.slider("Temperature", 0.0, 1.0, 1.0, 0.1)
|
237 |
-
generating_batch_size = st.slider("Generating Batch Size", 1, 10, 3, 1)
|
238 |
-
|
239 |
-
# Buttons
|
240 |
-
col1, col2 = st.columns(2)
|
241 |
-
with col1:
|
242 |
-
submit_button = st.button(
|
243 |
-
"Generate", type="primary", on_click=generate_examples_dataframe)
|
244 |
-
with col2:
|
245 |
generate_description_button = st.button(
|
246 |
"Generate Description", on_click=update_description_output_text)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
|
248 |
-
# Output column
|
249 |
-
|
250 |
-
description_output = st.text_area(
|
251 |
-
"Description", value=st.session_state.description_output_text, height=100)
|
252 |
-
|
253 |
-
col3, col4 = st.columns(2)
|
254 |
-
with col3:
|
255 |
-
generate_examples_directly_button = st.button(
|
256 |
-
"Generate Examples Directly", on_click=update_examples_directly_dataframe)
|
257 |
-
with col4:
|
258 |
-
analyze_input_button = st.button(
|
259 |
-
"Analyze Input", on_click=update_input_analysis_output_text)
|
260 |
-
|
261 |
-
examples_directly_output = st.dataframe(st.session_state.examples_directly_dataframe, use_container_width=True,
|
262 |
-
selection_mode="single-row", key="selected_example_directly_id", on_select=example_directly_selected)
|
263 |
-
input_analysis_output = st.text_area(
|
264 |
-
"Input Analysis", value=st.session_state.input_analysis_output_text, height=100)
|
265 |
-
generate_briefs_button = st.button(
|
266 |
-
"Generate Briefs", on_click=update_example_briefs_output_text)
|
267 |
-
example_briefs_output = st.text_area(
|
268 |
-
"Example Briefs", value=st.session_state.example_briefs_output_text, height=100)
|
269 |
-
generate_examples_from_briefs_button = st.button(
|
270 |
-
"Generate Examples from Briefs", on_click=update_examples_from_briefs_dataframe)
|
271 |
-
examples_from_briefs_output = st.dataframe(st.session_state.examples_from_briefs_dataframe, use_container_width=True,
|
272 |
-
selection_mode="single-row", key="selected_example_from_briefs_id", on_select=example_from_briefs_selected)
|
273 |
examples_output = st.dataframe(st.session_state.examples_dataframe, use_container_width=True,
|
274 |
selection_mode="single-row", key="selected_example_id", on_select=example_selected)
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
# input_json, model_name, generating_batch_size, temperature
|
284 |
-
# )
|
285 |
-
# description, examples_directly, input_analysis, new_example_briefs, examples_from_briefs, examples = result
|
286 |
-
# description_output = description
|
287 |
-
# examples_directly_output = examples_directly
|
288 |
-
# input_analysis_output = input_analysis
|
289 |
-
# example_briefs_output = new_example_briefs
|
290 |
-
# examples_from_briefs_output = examples_from_briefs
|
291 |
-
# examples_output = examples
|
292 |
-
# except Exception as e:
|
293 |
-
# st.error(f"An error occurred: {str(e)}")
|
294 |
-
|
295 |
-
# if generate_examples_directly_button:
|
296 |
-
# input_json = package_input_data()
|
297 |
-
# examples_directly_output = generate_examples_directly(
|
298 |
-
# description_output, input_json, generating_batch_size, model_name, temperature)
|
299 |
-
|
300 |
-
# if analyze_input_button:
|
301 |
-
# input_analysis_output = analyze_input(
|
302 |
-
# description_output, model_name, temperature)
|
303 |
-
|
304 |
-
# if generate_briefs_button:
|
305 |
-
# example_briefs_output = generate_briefs(
|
306 |
-
# description_output, input_analysis_output, generating_batch_size, model_name, temperature)
|
307 |
-
|
308 |
-
# if generate_examples_from_briefs_button:
|
309 |
-
# input_json = package_input_data()
|
310 |
-
# examples_from_briefs_output = generate_examples_from_briefs(
|
311 |
-
# description_output, example_briefs_output, input_json, generating_batch_size, model_name, temperature)
|
|
|
210 |
|
211 |
|
212 |
# Streamlit UI
|
213 |
+
st.title("LLM Task Example Generator")
|
214 |
+
st.markdown("Enter input-output pairs in the table below to generate a task description, analysis, and additional examples.")
|
215 |
|
216 |
# Input column
|
217 |
input_data = st.data_editor(
|
|
|
224 |
},
|
225 |
)
|
226 |
|
227 |
+
with st.expander("Model Settings"):
|
228 |
+
model_name = st.selectbox(
|
229 |
+
"Model Name",
|
230 |
+
["llama3-70b-8192", "llama3-8b-8192", "llama-3.1-70b-versatile",
|
231 |
+
"llama-3.1-8b-instant", "gemma2-9b-it"],
|
232 |
+
index=0
|
233 |
+
)
|
234 |
+
temperature = st.slider("Temperature", 0.0, 1.0, 1.0, 0.1)
|
235 |
+
generating_batch_size = st.slider("Generating Batch Size", 1, 10, 3, 1)
|
236 |
|
237 |
+
submit_button = st.button(
|
238 |
+
"Generate", type="primary", on_click=generate_examples_dataframe)
|
239 |
+
|
240 |
+
with st.expander("Description and Analysis"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
generate_description_button = st.button(
|
242 |
"Generate Description", on_click=update_description_output_text)
|
243 |
+
|
244 |
+
description_output = st.text_area(
|
245 |
+
"Description", value=st.session_state.description_output_text, height=100)
|
246 |
+
|
247 |
+
col3, col4 = st.columns(2)
|
248 |
+
with col3:
|
249 |
+
generate_examples_directly_button = st.button(
|
250 |
+
"Generate Examples Directly", on_click=update_examples_directly_dataframe)
|
251 |
+
with col4:
|
252 |
+
analyze_input_button = st.button(
|
253 |
+
"Analyze Input", on_click=update_input_analysis_output_text)
|
254 |
+
|
255 |
+
examples_directly_output = st.dataframe(st.session_state.examples_directly_dataframe, use_container_width=True,
|
256 |
+
selection_mode="single-row", key="selected_example_directly_id",
|
257 |
+
on_select=example_directly_selected)
|
258 |
+
input_analysis_output = st.text_area(
|
259 |
+
"Input Analysis", value=st.session_state.input_analysis_output_text, height=100)
|
260 |
+
generate_briefs_button = st.button(
|
261 |
+
"Generate Briefs", on_click=update_example_briefs_output_text)
|
262 |
+
example_briefs_output = st.text_area(
|
263 |
+
"Example Briefs", value=st.session_state.example_briefs_output_text, height=100)
|
264 |
+
generate_examples_from_briefs_button = st.button(
|
265 |
+
"Generate Examples from Briefs", on_click=update_examples_from_briefs_dataframe)
|
266 |
+
examples_from_briefs_output = st.dataframe(st.session_state.examples_from_briefs_dataframe, use_container_width=True,
|
267 |
+
selection_mode="single-row", key="selected_example_from_briefs_id",
|
268 |
+
on_select=example_from_briefs_selected)
|
269 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
examples_output = st.dataframe(st.session_state.examples_dataframe, use_container_width=True,
|
271 |
selection_mode="single-row", key="selected_example_id", on_select=example_selected)
|
272 |
+
|
273 |
+
def show_sidebar():
|
274 |
+
if st.session_state.selected_example is not None:
|
275 |
+
with st.sidebar:
|
276 |
+
new_example_json = st.text_area(
|
277 |
+
"New Example JSON", value=st.session_state.selected_example, height=100)
|
278 |
+
|
279 |
+
show_sidebar()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|