Spaces:
Running
Running
Syncing inputs works.
Browse files
app/streamlit_meta_prompt.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import streamlit as st
|
2 |
import json
|
3 |
import logging
|
@@ -461,6 +462,8 @@ with st.sidebar:
|
|
461 |
aggressive_exploration_input = st.checkbox("Aggressive Exploration", False)
|
462 |
|
463 |
# Initialize session state
|
|
|
|
|
464 |
if 'initial_system_message' not in st.session_state:
|
465 |
st.session_state.initial_system_message = ""
|
466 |
if 'initial_acceptance_criteria' not in st.session_state:
|
@@ -485,8 +488,17 @@ def copy_acceptance_criteria():
|
|
485 |
st.session_state.initial_acceptance_criteria = st.session_state.acceptance_criteria_output
|
486 |
|
487 |
def clear_session_state():
|
488 |
-
|
489 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
490 |
|
491 |
if active_model_tab == "Simple":
|
492 |
simple_model_name = simple_model_name_input
|
@@ -531,10 +543,11 @@ max_output_age = max_output_age_input
|
|
531 |
aggressive_exploration = aggressive_exploration_input
|
532 |
|
533 |
data_editor_data = st.data_editor(
|
534 |
-
|
|
|
535 |
column_config={
|
536 |
-
"
|
537 |
-
"
|
538 |
},
|
539 |
hide_index=True,
|
540 |
use_container_width=True,
|
@@ -547,17 +560,19 @@ with col1:
|
|
547 |
initial_system_message = st.text_area("Initial System Message", st.session_state.initial_system_message).strip()
|
548 |
acceptance_criteria = st.text_area("Acceptance Criteria", st.session_state.initial_acceptance_criteria).strip()
|
549 |
|
550 |
-
col1_1, col1_2 = st.columns(
|
551 |
with col1_1:
|
552 |
generate_button_clicked = st.button("Generate", type="primary")
|
553 |
with col1_2:
|
|
|
|
|
554 |
clear_button_clicked = st.button("Clear", on_click=clear_session_state)
|
555 |
|
556 |
with col2:
|
557 |
if generate_button_clicked:
|
558 |
try:
|
559 |
-
user_message = data_editor_data[
|
560 |
-
expected_output = data_editor_data[
|
561 |
|
562 |
if active_model_tab == "Simple":
|
563 |
system_message, output, analysis, acceptance_criteria, chat_log = process_message_with_single_llm(
|
|
|
1 |
+
import pandas as pd
|
2 |
import streamlit as st
|
3 |
import json
|
4 |
import logging
|
|
|
462 |
aggressive_exploration_input = st.checkbox("Aggressive Exploration", False)
|
463 |
|
464 |
# Initialize session state
|
465 |
+
if 'meta_prompt_input_data' not in st.session_state:
|
466 |
+
st.session_state.meta_prompt_input_data = pd.DataFrame(columns=["Input", "Output"])
|
467 |
if 'initial_system_message' not in st.session_state:
|
468 |
st.session_state.initial_system_message = ""
|
469 |
if 'initial_acceptance_criteria' not in st.session_state:
|
|
|
488 |
st.session_state.initial_acceptance_criteria = st.session_state.acceptance_criteria_output
|
489 |
|
490 |
def clear_session_state():
|
491 |
+
st.session_state.meta_prompt_input_data = pd.DataFrame(columns=["Input", "Output"])
|
492 |
+
st.session_state.initial_system_message = ""
|
493 |
+
st.session_state.initial_acceptance_criteria = ""
|
494 |
+
st.session_state.system_message_output = ""
|
495 |
+
st.session_state.output = ""
|
496 |
+
st.session_state.analysis = ""
|
497 |
+
st.session_state.acceptance_criteria_output = ""
|
498 |
+
st.session_state.chat_log = []
|
499 |
+
|
500 |
+
def sync_input_data():
|
501 |
+
st.session_state.sample_generator_input_data = data_editor_data.copy()
|
502 |
|
503 |
if active_model_tab == "Simple":
|
504 |
simple_model_name = simple_model_name_input
|
|
|
543 |
aggressive_exploration = aggressive_exploration_input
|
544 |
|
545 |
data_editor_data = st.data_editor(
|
546 |
+
st.session_state.meta_prompt_input_data,
|
547 |
+
num_rows="dynamic",
|
548 |
column_config={
|
549 |
+
"Input": st.column_config.TextColumn("Input", width="large"),
|
550 |
+
"Output": st.column_config.TextColumn("Output", width="large"),
|
551 |
},
|
552 |
hide_index=True,
|
553 |
use_container_width=True,
|
|
|
560 |
initial_system_message = st.text_area("Initial System Message", st.session_state.initial_system_message).strip()
|
561 |
acceptance_criteria = st.text_area("Acceptance Criteria", st.session_state.initial_acceptance_criteria).strip()
|
562 |
|
563 |
+
col1_1, col1_2, col1_3 = st.columns(3)
|
564 |
with col1_1:
|
565 |
generate_button_clicked = st.button("Generate", type="primary")
|
566 |
with col1_2:
|
567 |
+
sync_button_clicked = st.button("Sync", on_click=sync_input_data)
|
568 |
+
with col1_3:
|
569 |
clear_button_clicked = st.button("Clear", on_click=clear_session_state)
|
570 |
|
571 |
with col2:
|
572 |
if generate_button_clicked:
|
573 |
try:
|
574 |
+
user_message = data_editor_data["Input"][0].strip()
|
575 |
+
expected_output = data_editor_data["Output"][0].strip()
|
576 |
|
577 |
if active_model_tab == "Simple":
|
578 |
system_message, output, analysis, acceptance_criteria, chat_log = process_message_with_single_llm(
|
app/streamlit_sample_generator.py
CHANGED
@@ -144,8 +144,8 @@ def example_selected():
|
|
144 |
|
145 |
|
146 |
# Session State
|
147 |
-
if '
|
148 |
-
st.session_state.
|
149 |
|
150 |
if 'description_output_text' not in st.session_state:
|
151 |
st.session_state.description_output_text = ''
|
@@ -245,7 +245,7 @@ def import_input_data_from_json():
|
|
245 |
data = st.session_state.input_file.getvalue()
|
246 |
data = json.loads(data)
|
247 |
data = [{k.capitalize(): v for k, v in d.items()} for d in data]
|
248 |
-
st.session_state.
|
249 |
except Exception as e:
|
250 |
st.warning(f"Failed to import JSON: {str(e)}")
|
251 |
|
@@ -277,13 +277,28 @@ def add_new_suggestion():
|
|
277 |
st.session_state.suggestions.append(st.session_state.new_suggestion)
|
278 |
st.session_state.new_suggestion = "" # Clear the input field
|
279 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
280 |
# Streamlit UI
|
281 |
st.title("LLM Task Example Generator")
|
282 |
st.markdown("Enter input-output pairs in the table below to generate a task description, analysis, and additional examples.")
|
283 |
|
284 |
# Input column
|
285 |
input_data = st.data_editor(
|
286 |
-
st.session_state.
|
287 |
num_rows="dynamic",
|
288 |
use_container_width=True,
|
289 |
column_config={
|
@@ -315,8 +330,16 @@ with st.expander("Model Settings"):
|
|
315 |
temperature = st.slider("Temperature", 0.0, 1.0, 1.0, 0.1)
|
316 |
generating_batch_size = st.slider("Generating Batch Size", 1, 10, 3, 1)
|
317 |
|
318 |
-
|
319 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
|
321 |
with st.expander("Description and Analysis"):
|
322 |
generate_description_button = st.button(
|
@@ -365,8 +388,8 @@ examples_output = st.dataframe(st.session_state.examples_dataframe, use_containe
|
|
365 |
|
366 |
def append_selected_to_input_data():
|
367 |
if st.session_state.selected_example is not None:
|
368 |
-
st.session_state.
|
369 |
-
[st.session_state.
|
370 |
st.session_state.selected_example = None
|
371 |
|
372 |
def show_sidebar():
|
|
|
144 |
|
145 |
|
146 |
# Session State
|
147 |
+
if 'sample_generator_input_data' not in st.session_state:
|
148 |
+
st.session_state.sample_generator_input_data = pd.DataFrame(columns=["Input", "Output"])
|
149 |
|
150 |
if 'description_output_text' not in st.session_state:
|
151 |
st.session_state.description_output_text = ''
|
|
|
245 |
data = st.session_state.input_file.getvalue()
|
246 |
data = json.loads(data)
|
247 |
data = [{k.capitalize(): v for k, v in d.items()} for d in data]
|
248 |
+
st.session_state.sample_generator_input_data = pd.DataFrame(data)
|
249 |
except Exception as e:
|
250 |
st.warning(f"Failed to import JSON: {str(e)}")
|
251 |
|
|
|
277 |
st.session_state.suggestions.append(st.session_state.new_suggestion)
|
278 |
st.session_state.new_suggestion = "" # Clear the input field
|
279 |
|
280 |
+
def sync_input_data():
|
281 |
+
st.session_state.meta_prompt_input_data = input_data.copy()
|
282 |
+
st.session_state.sample_generator_input_data = input_data.copy()
|
283 |
+
|
284 |
+
def clear_session_state():
|
285 |
+
st.session_state.sample_generator_input_data = pd.DataFrame(columns=["Input", "Output"])
|
286 |
+
st.session_state.description_output_text = ''
|
287 |
+
st.session_state.suggestions = []
|
288 |
+
st.session_state.input_analysis_output_text = ''
|
289 |
+
st.session_state.example_briefs_output_text = ''
|
290 |
+
st.session_state.examples_from_briefs_dataframe = pd.DataFrame(columns=["Input", "Output"])
|
291 |
+
st.session_state.examples_directly_dataframe = pd.DataFrame(columns=["Input", "Output"])
|
292 |
+
st.session_state.examples_dataframe = pd.DataFrame(columns=["Input", "Output"])
|
293 |
+
st.session_state.selected_example = None
|
294 |
+
|
295 |
# Streamlit UI
|
296 |
st.title("LLM Task Example Generator")
|
297 |
st.markdown("Enter input-output pairs in the table below to generate a task description, analysis, and additional examples.")
|
298 |
|
299 |
# Input column
|
300 |
input_data = st.data_editor(
|
301 |
+
st.session_state.sample_generator_input_data,
|
302 |
num_rows="dynamic",
|
303 |
use_container_width=True,
|
304 |
column_config={
|
|
|
330 |
temperature = st.slider("Temperature", 0.0, 1.0, 1.0, 0.1)
|
331 |
generating_batch_size = st.slider("Generating Batch Size", 1, 10, 3, 1)
|
332 |
|
333 |
+
col1, col2, col3 = st.columns(3)
|
334 |
+
with col1:
|
335 |
+
submit_button = st.button(
|
336 |
+
"Generate", type="primary", on_click=generate_examples_dataframe)
|
337 |
+
with col2:
|
338 |
+
sync_button = st.button(
|
339 |
+
"Sync", on_click=sync_input_data)
|
340 |
+
with col3:
|
341 |
+
clear_button = st.button(
|
342 |
+
"Clear", on_click=clear_session_state)
|
343 |
|
344 |
with st.expander("Description and Analysis"):
|
345 |
generate_description_button = st.button(
|
|
|
388 |
|
389 |
def append_selected_to_input_data():
|
390 |
if st.session_state.selected_example is not None:
|
391 |
+
st.session_state.sample_generator_input_data = pd.concat(
|
392 |
+
[st.session_state.sample_generator_input_data, st.session_state.selected_example], ignore_index=True)
|
393 |
st.session_state.selected_example = None
|
394 |
|
395 |
def show_sidebar():
|