Spaces:
Runtime error
Runtime error
File size: 1,159 Bytes
ec44ead |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
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.")
# Initialize session state variables if they don't exist
if "input_list" not in st.session_state:
st.session_state.input_list = [""]
# Function to add a new input field
def add_input():
st.session_state.input_list.append("")
# Function to remove an input field
def remove_input(index):
st.session_state.input_list.pop(index)
# Display the input fields
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,)
)
# Button to add new input field
st.button("Add new input", on_click=add_input)
return st.session_state.input_list
|