I removed os but its still showing that error. But more importantly I acually have a UI layout doubt. This is my current code for a chatbot layout (inside a tab & I’ve noticed tabs have made streamlit layouts so difficult to work with):
def chat_content():
st.session_state[‘messages’].append({“role”: “user”, “content”: st.session_state[‘content’]})
with tab4:
st.title(“Feedback Insight Chat”)
if ‘messages’ not in st.session_state:
st.session_state[‘messages’] =
if ‘categories_analysis’ not in st.session_state or not st.session_state[‘categories_analysis’]:
st.write(“No feedback summaries available. Please visit the ‘Feedback Categorization’ tab first.”)
with st.container():
for message in st.session_state['messages']:
with st.chat_message(message["role"]):
st.markdown(message["content"])
with st.form("chat_form"):
cols = st.columns((6, 1))
cols[0].text_input(
"Chat",
value="",
label_visibility="collapsed",
key="content"
)
submit_button = cols[1].form_submit_button(
"Submit",
type="primary",
on_click=chat_content
)
prompt = st.session_state.get('content')
with st.chat_message(“assistant”):
stream = client.chat.completions.create(
model=st.session_state[“azure_openai_model”],
messages=[
{“role”: “system”, “content”: system_message[“content”]},
{“role”: “user”, “content”: user_message[“content”]}
],
stream=True,
temperature=0.2
)
response = st.write_stream(stream)
st.session_state.messages.append({“role”: “assistant”, “content”: response})
I’ve attached a screenshot of how this looks like, I dont understand why the input form appears before the response is streamed/generated. It looks really awkward and I want the input form to be at the bottom of the page with the entire chat history above.
I used to use chat_input before but I was recommended from this post to change it when using tabs: Chat input layout adjustments
Can you help with fixing this layout?