# Streamlitcallbackhandler hide empty text

**URL:** <https://discuss.streamlit.io/t/streamlitcallbackhandler-hide-empty-text/64982>\
**Category:** Custom Components\
**Tags:** container, needs-more-info, ui, debugging\
**Created:** [March 18, 2024, 11:50am UTC](https://discuss.streamlit.io/t/streamlitcallbackhandler-hide-empty-text/64982 "2024-03-18T11:50:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![starskiin3d](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@starskiin3d](https://discuss.streamlit.io/u/starskiin3d)\
**Post date:** [March 18, 2024, 11:50am UTC](https://discuss.streamlit.io/t/streamlitcallbackhandler-hide-empty-text/64982/1 "2024-03-18T11:50:55Z")

</div>

Hello, I have implemented streamlitcallbackhandler with my chat bot, but before it writes the answer there is empty text displayed.

Is there any way to hide empty text?

 ![hide empty text](https://global.discourse-cdn.com/streamlit/original/3X/5/8/585ec93095dca12478abb86cdbbcda1b51ec67a1.png)

```auto
callback = StreamlitCallbackHandler(st.empty())
llm = ChatAnthropic(temperature=0.1, 
                    max_tokens=1000, 
                    model_name=claude- 2,
                    streaming=True,callbacks=[callback])
result = qa.invoke({"question": prompt, 
                    "chat_history": [(message["role"], 
                    message["content"]) for message in st.session_state.messages]})

```

---

<div class="post-metadata">

**Author:** ![tonykip](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/tonykip/32/45167_2.png) [@tonykip](https://discuss.streamlit.io/u/tonykip)\
**Post date:** [March 18, 2024, 3:30pm UTC](https://discuss.streamlit.io/t/streamlitcallbackhandler-hide-empty-text/64982/2 "2024-03-18T15:30:41Z")

</div>

Hi @starskiin3d,

Thanks for sharing your question with the community! 🎈 Please update your debugging post to include a **code snippet** and a **link to your app’s public GitHub repo** – this will allow the community to help you find an answer as quickly as possible. In the meantime, this post will be tagged as `needs-more-info`.

---

<div class="post-metadata">

**Author:** ![starskiin3d](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@starskiin3d](https://discuss.streamlit.io/u/starskiin3d)\
**Post date:** [March 18, 2024, 3:38pm UTC](https://discuss.streamlit.io/t/streamlitcallbackhandler-hide-empty-text/64982/3 "2024-03-18T15:38:55Z")

</div>

Done as you requested.

---

<div class="post-metadata">

**Author:** ![tonykip](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/tonykip/32/45167_2.png) [@tonykip](https://discuss.streamlit.io/u/tonykip)\
**Post date:** [March 18, 2024, 3:48pm UTC](https://discuss.streamlit.io/t/streamlitcallbackhandler-hide-empty-text/64982/4 "2024-03-18T15:48:55Z")

</div>

Based on the code you provided, it seems the empty is caused my passing in the `st.empty` to the callback handler in this line:

```auto
callback = StreamlitCallbackHandler(st.empty())

```

Maybe try using a container instead (I have not tested this, so let me know if it works):

```auto
callback = StreamlitCallbackHandler(st.container())

```

---

<div class="post-metadata">

**Author:** ![starskiin3d](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@starskiin3d](https://discuss.streamlit.io/u/starskiin3d)\
**Post date:** [March 18, 2024, 3:52pm UTC](https://discuss.streamlit.io/t/streamlitcallbackhandler-hide-empty-text/64982/5 "2024-03-18T15:52:17Z")

</div>

Tried that originally, same issue, the reason why i use st.empty is that once bot finishes with response there is no this small re-render happening at the end, it just finishes the process more smoothly.

But to answer your question is it still happens with st.container()

---

<div class="post-metadata">

**Author:** ![tonykip](https://sea2.discourse-cdn.com/streamlit/user_avatar/discuss.streamlit.io/tonykip/32/45167_2.png) [@tonykip](https://discuss.streamlit.io/u/tonykip)\
**Post date:** [March 19, 2024, 12:13pm UTC](https://discuss.streamlit.io/t/streamlitcallbackhandler-hide-empty-text/64982/6 "2024-03-19T12:13:09Z")

</div>

I’ll give this a try on my end and let you know. Just to be clear, you just want the “empty” message not to show before the it starts writing the processes in the expander right?

---

<div class="post-metadata">

**Author:** ![starskiin3d](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@starskiin3d](https://discuss.streamlit.io/u/starskiin3d)\
**Post date:** [March 19, 2024, 12:18pm UTC](https://discuss.streamlit.io/t/streamlitcallbackhandler-hide-empty-text/64982/7 "2024-03-19T12:18:14Z")

</div>

Yeah, while waiting there should be nothing there.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/streamlit/original/3X/c/f/cf4c2ee0d938358f82448c5fe4b9c3c91d7ce19c.svg) [@system](https://discuss.streamlit.io/u/system)\
**Post date:** [September 15, 2024, 12:19pm UTC](https://discuss.streamlit.io/t/streamlitcallbackhandler-hide-empty-text/64982/8 "2024-09-15T12:19:06Z")

</div>

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
