Spaces:
Running
Running
Select sample for generating prompt.
Browse files- app/streamlit_tab_app.py +24 -12
app/streamlit_tab_app.py
CHANGED
@@ -409,15 +409,20 @@ def clear_session_state():
|
|
409 |
def pull_sample_description():
|
410 |
st.session_state.initial_system_message = description_output
|
411 |
|
|
|
|
|
|
|
412 |
def generate_callback():
|
413 |
try:
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
|
|
|
|
418 |
|
419 |
-
input_acceptance_criteria = initial_acceptance_criteria.strip()
|
420 |
-
input_system_message = initial_system_message.strip()
|
421 |
|
422 |
if model_tab == "Simple":
|
423 |
system_message, output, analysis, acceptance_criteria, chat_log = process_message_with_single_llm(
|
@@ -506,7 +511,7 @@ st.title("Meta Prompt")
|
|
506 |
st.markdown("Enter input-output pairs as the examples for the prompt.")
|
507 |
data_editor_data = st.data_editor(
|
508 |
st.session_state.shared_input_data,
|
509 |
-
|
510 |
num_rows="dynamic",
|
511 |
column_config={
|
512 |
"Input": st.column_config.TextColumn("Input", width="large"),
|
@@ -514,18 +519,16 @@ data_editor_data = st.data_editor(
|
|
514 |
},
|
515 |
hide_index=False,
|
516 |
use_container_width=True,
|
|
|
517 |
)
|
518 |
|
519 |
with st.expander("Data Management"):
|
520 |
-
# col1, col2 = st.columns(2)
|
521 |
-
# with col1:
|
522 |
input_file = st.file_uploader(
|
523 |
label="Import Input Data from JSON",
|
524 |
type="json",
|
525 |
key="input_file",
|
526 |
on_change=import_input_data_from_json
|
527 |
)
|
528 |
-
# with col2:
|
529 |
export_button = st.button( # Add the export button
|
530 |
"Export Input Data to JSON", on_click=export_input_data_to_json
|
531 |
)
|
@@ -601,6 +604,17 @@ with tab_prompting:
|
|
601 |
# Prompting UI
|
602 |
st.markdown("Generate the prompt with the above input-output pairs.")
|
603 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
604 |
generate_button_clicked = st.button("Generate", key="generate_button",
|
605 |
on_click=generate_callback,
|
606 |
type="primary", use_container_width=True)
|
@@ -705,12 +719,10 @@ with tab_prompting:
|
|
705 |
"Suggester Temperature", 0.0, 1.0, 0.1, 0.1
|
706 |
)
|
707 |
|
708 |
-
# st.header("Prompt Template Settings")
|
709 |
prompt_template_group_input = st.selectbox(
|
710 |
"Prompt Template Group", config.prompt_templates.keys(), index=0
|
711 |
)
|
712 |
|
713 |
-
# st.header("Advanced Settings")
|
714 |
recursion_limit_input = st.number_input("Recursion Limit", 1, 100, 16, 1)
|
715 |
max_output_age_input = st.number_input("Max Output Age", 1, 10, 2, 1)
|
716 |
aggressive_exploration_input = st.checkbox("Aggressive Exploration", False)
|
|
|
409 |
def pull_sample_description():
|
410 |
st.session_state.initial_system_message = description_output
|
411 |
|
412 |
+
def update_working_sample_options():
|
413 |
+
pass
|
414 |
+
|
415 |
def generate_callback():
|
416 |
try:
|
417 |
+
# Get the index of the selected sample
|
418 |
+
selected_index = selected_sample.split(":")[0].split()[1]
|
419 |
+
selected_index = int(selected_index)
|
420 |
+
|
421 |
+
user_message = data_editor_data.loc[selected_index, "Input"].strip()
|
422 |
+
expected_output = data_editor_data.loc[selected_index, "Output"].strip()
|
423 |
|
424 |
+
input_acceptance_criteria = initial_acceptance_criteria.strip()
|
425 |
+
input_system_message = initial_system_message.strip()
|
426 |
|
427 |
if model_tab == "Simple":
|
428 |
system_message, output, analysis, acceptance_criteria, chat_log = process_message_with_single_llm(
|
|
|
511 |
st.markdown("Enter input-output pairs as the examples for the prompt.")
|
512 |
data_editor_data = st.data_editor(
|
513 |
st.session_state.shared_input_data,
|
514 |
+
key="data_editor",
|
515 |
num_rows="dynamic",
|
516 |
column_config={
|
517 |
"Input": st.column_config.TextColumn("Input", width="large"),
|
|
|
519 |
},
|
520 |
hide_index=False,
|
521 |
use_container_width=True,
|
522 |
+
on_change=update_working_sample_options
|
523 |
)
|
524 |
|
525 |
with st.expander("Data Management"):
|
|
|
|
|
526 |
input_file = st.file_uploader(
|
527 |
label="Import Input Data from JSON",
|
528 |
type="json",
|
529 |
key="input_file",
|
530 |
on_change=import_input_data_from_json
|
531 |
)
|
|
|
532 |
export_button = st.button( # Add the export button
|
533 |
"Export Input Data to JSON", on_click=export_input_data_to_json
|
534 |
)
|
|
|
604 |
# Prompting UI
|
605 |
st.markdown("Generate the prompt with the above input-output pairs.")
|
606 |
|
607 |
+
# Create options for the selectbox
|
608 |
+
sample_options = [f"Sample {i}: {row['Input'][:30]}..." for i, row in data_editor_data.iterrows()]
|
609 |
+
|
610 |
+
# Create the selectbox
|
611 |
+
selected_sample = st.selectbox(
|
612 |
+
"Working Sample",
|
613 |
+
options=sample_options,
|
614 |
+
index=0,
|
615 |
+
# key="working_sample"
|
616 |
+
)
|
617 |
+
|
618 |
generate_button_clicked = st.button("Generate", key="generate_button",
|
619 |
on_click=generate_callback,
|
620 |
type="primary", use_container_width=True)
|
|
|
719 |
"Suggester Temperature", 0.0, 1.0, 0.1, 0.1
|
720 |
)
|
721 |
|
|
|
722 |
prompt_template_group_input = st.selectbox(
|
723 |
"Prompt Template Group", config.prompt_templates.keys(), index=0
|
724 |
)
|
725 |
|
|
|
726 |
recursion_limit_input = st.number_input("Recursion Limit", 1, 100, 16, 1)
|
727 |
max_output_age_input = st.number_input("Max Output Age", 1, 10, 2, 1)
|
728 |
aggressive_exploration_input = st.checkbox("Aggressive Exploration", False)
|