Hi,
I’m new to Streamlit and I have a question about using callback functions.
I want to create a prompt that calls a function “process_message” when on-submit
This codes works
def process_message():
st.write(“test”)
prompt = st.chat_input(" Ask your question here: ",on_submit=process_message)
As a next step, I want to access the text entered in my prompt within my callback function.
How can I do that?
Regards
Goyo
2
In three easy steps:
- Add a key to the chat input.
prompt = st.chat_input("Ask your question here: ", on_submit=process_message, key="prompt")
- Use session state and the key to access the value.
def process_message():
st.write(st.session_state.prompt)
- Profit!
system
Closed
3
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.