Bring User_Input textbox at bottom of page


How to bring chat box at bottom of page , right now it was coming down only when I type something in chatbot

Steps to reproduce

Code snippet:

import openai
import streamlit as st
from streamlit_chat import message

model = "gpt-3.5-turbo"
openai.api_key = "secreat_key"
# Setting page title and header
st.set_page_config(page_title="MYBOT", page_icon=":robot_face:")
st.markdown("<h1 style='text-align: center;'>MYBOT- a totally harmless chatbot 😬</h1>", unsafe_allow_html=True)

# Initialise session state variables
if 'generated' not in st.session_state:
    st.session_state['generated'] = []
if 'past' not in st.session_state:
    st.session_state['past'] = []
if 'messages' not in st.session_state:
    st.session_state['messages'] = [
        {"role": "system", "content": "You are a helpful assistant."}
# generate a response
def generate_response(prompt):
    st.session_state['messages'].append({"role": "user", "content": prompt})

    completion = openai.ChatCompletion.create(
    response = completion.choices[0].message.content
    st.session_state['messages'].append({"role": "assistant", "content": response})
    return response
# container for chat history
response_container = st.container()
# container for text box
container = st.container()

with container:
    with st.form(key='my_form', clear_on_submit=True):
        user_input = st.text_area("You:", key='input', height=100)
        submit_button = st.form_submit_button(label='Send')
    if submit_button and user_input:
        output= generate_response(user_input)

if st.session_state['generated']:
    with response_container:
        for i in range(len(st.session_state['generated'])):
            message(st.session_state["past"][i], is_user=True, key=str(i) + '_user')
            message(st.session_state["generated"][i], key=str(i))

Hey @Nitish,

Just to clarify, are you hoping to have the chatbot pinned to the bottom of the page?

1 Like

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