This was my first time making a package and publishing it so forgive me if I made any mistakes, I am open to suggestions but might take time to act on them , even the first time making something using react. Thank you Streamlit team, it was fun making it.
Greetings, Yashppawar. Youâve got a great concept going there, however, is there any way you could put the chatbox below the prior chats, like in Whatsapp?
Hello @KinePi, Thank you
yes, it is possible to have the text input below the prior chats, it can be achieved using st.empty() as a placeholder
import streamlit as st
from streamlit_chat import message
placeholder = st.empty()
input_ = st.text_input("you:")
message_history.append(input_)
with placeholder.container():
for message_ in message_history:
message(message_)
However, in this method, if there are many messages, the text_input gets out of the viewing area, maybe will have to limit the number of messages to be displayed, or maybe have the container of fixed height and a scroll bar (not sure how to do that)
Edit: was just playing around and I have the following code, but there is a bit of delay between the previous messages and the latest message.
better one I think
import streamlit as st
from streamlit_chat import message
for message_ in message_history:
message(message_) # display all the previous message
placeholder = st.empty() # placeholder for latest message
input_ = st.text_input("you:")
message_history.append(input_)
with placeholder.container():
message(message_history[-1]) # display the latest message
Such a great component!! Now I can make a QA system with it, thank you so much! Iâm wondering will you add function of returning picture or datatable?
Didnât have any plan for adding HTML or Markdown support, not sure if â\nâ works, if not will add that soon. We can try to add HTML & MarkDown support I am afraid we might have to write a lot more CSS for that., will try it after January 3, 2022 (Exams)
Iâm try âstreamlit-chatâ. but happened error following
ImportError: cannot import name âLiteralâ from âtypingâ (/usr/lib/python3.7/typing.py)
Traceback:
File "/usr/local/lib/python3.7/dist-packages/streamlit/script_runner.py", line 430, in _run_script
exec(code, module.__dict__)File "/content/app.py", line 7, in <module>
from streamlit_chat import messageFile "/usr/local/lib/python3.7/dist-packages/streamlit_chat/__init__.py", line 3, in <module>
from typing import Any, Literal, Optional, Union
```-----------
If youâre able to switch to an environment with python 3.8+ you should at least get past that import error.
See pep 586
If you need to work with 3.7, Iâd suggest opening an issue on the st-chat github.
Maybe they can include an option with typing_extensions or without Literal
Is there a more recent example of this that I can look at ?
My text seems to show only the latest text and is not showing as the user text , is showing as the bot text instead.
Pls refer to my code , based on the example from above post , below.
Thanks!
import streamlit as st
from streamlit_chat import message
message_history= []
message("My message")
for message_ in message_history:
message(message_) # display all the previous message
placeholder = st.empty() # placeholder for latest message
input_ = st.text_input("you:")
message_history.append(input_)
with placeholder.container():
message(message_history[-1]) # display the latest message
I am able to manage user input at the base. however, if the response is an HTML page then it is displayed below the text box. I did not face this issue when the response is text.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking âAccept allâ, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.