streamlit / streamlit

Streamlit ā€” A faster way to build and share data apps.
https://streamlit.io
Apache License 2.0
34.82k stars 3.02k forks source link

Sneaky issue with `st.chat_input()` when dynamically updating `placeholder` argument #9565

Open spencer-thompson opened 5 hours ago

spencer-thompson commented 5 hours ago

Checklist

Summary

When dynamically updating the placeholder inside st.chat_input() messages can not send (premature rerun?). For example randomly choosing a placeholder causes the message to be lost.

Reproducible Code Example

import streamlit as st
import random

if user_input := st.chat_input(
    random.choice(["say hi", "say hey", "say hello"]),
):

    st.chat_message("user").markdown(user_input)

    with st.chat_message("assistant"):
        st.write("testing")

Steps To Reproduce

  1. pip install streamlit
  2. Copy the code sample above
  3. streamlit run app.py

Expected Behavior

It appears to be a premature rerun, the code should display a new chat message but does not. Upon running the code it will be clear.

Current Behavior

It appears to be a premature rerun. The message simply seems to disappear.

Is this a regression?

Debug info

Additional Information

Certainly not a critical bug, but given that streamlit is incredibly useful for LLM/Chat Apps it would be good to at least document.

github-actions[bot] commented 5 hours ago

If this issue affects you, please react with a šŸ‘ (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits