To activate the scroll feature of streamlit_chat while keeping the input box in its original position, you can place the input box inside a fixed container and set the height of the chat messages container to a fixed value.
Here is an example code snippet:
import streamlit as st
from streamlit_chat import chat
st.title("Chat Example")
# Initialize chat
messages = []
# Define chat parameters
chat_params = {
"scroll_to_bottom": True,
"input_text_color": "black",
"output_text_color": "black"
}
# Define fixed container for input box
input_container = st.beta_container()
with input_container:
input_text = st.text_input("Type your message here:")
if st.button("Send"):
messages.append({"text": input_text, "is_user_message": True})
input_text = ""
# Define chat messages container with fixed height
chat_container = st.beta_container()
with chat_container:
chat(messages, **chat_params, height=500)
In this code, the input_container
container holds the input box and has a fixed position on the page. The chat_container
container holds the chat messages and has a fixed height of 500 pixels. This allows the scrolling feature to work independently of the input box position.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-07-23 11:00:00 +0000
Seen: 16 times
Last updated: Jun 27 '21
How to obtain a Null value in combo boxes?
What is the process to create an evenly spaced gap using flex box CSS?
Can I utilize a digital dialogue box for selecting both date and time?
How does the accuracy of Scipy FFT compare to that of the analytical FT of a box function?
How can user input be added to an array using a loop in C# and then displayed through printing?
If the chips occupy 80% of the space, what is the best way to package the remaining input?