Ask Your Question
0

How can the scroll feature of streamlit_chat be activated while the input box remains in its original position?

asked 2022-07-23 11:00:00 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-06-27 18:00:00 +0000

plato gravatar image

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.

edit flag offensive delete link more

Your Answer

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

Add Answer


Question Tools

Stats

Asked: 2022-07-23 11:00:00 +0000

Seen: 15 times

Last updated: Jun 27 '21