|
import os, sys |
|
from os.path import dirname as up |
|
|
|
sys.path.append(os.path.abspath(os.path.join(up(__file__), os.pardir))) |
|
|
|
from utils import * |
|
|
|
|
|
def manage_input_fields(): |
|
st.write("Enter a single or multiple prompts.") |
|
|
|
|
|
if "input_list" not in st.session_state: |
|
st.session_state.input_list = [""] |
|
|
|
|
|
def add_input(): |
|
st.session_state.input_list.append("") |
|
|
|
|
|
def remove_input(index): |
|
st.session_state.input_list.pop(index) |
|
|
|
|
|
for index, value in enumerate(st.session_state.input_list): |
|
col1, col2 = st.columns([4, 1]) |
|
with col1: |
|
st.session_state.input_list[index] = st.text_input( |
|
f"Input Prompt: {index+1}", value=value |
|
) |
|
with col2: |
|
st.button( |
|
"Remove", key=f"remove_{index}", on_click=remove_input, args=(index,) |
|
) |
|
|
|
|
|
st.button("Add new input", on_click=add_input) |
|
|
|
return st.session_state.input_list |
|
|