I would like to be able to stream the conversation and have the ability to keep all…
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
I would like to be able to stream the conversation and have the ability to keep all records.
This is the streaming API request, which streams like (for: return yield) request_completion(url_input, api_key_input, chat_prompt, parameters, True)
This is an example of a dialog component printing out all records. if "messages" not in st.session_state: st.session_state.messages = [] if user_input := st.chat_input("Say something"): st.session_state.messages.append({"role": "user", "content": user_input}) st.session_state.messages.append({"role": "assistant", "content": api's output})
codefor message in st.session_state.messages: with chatbox.chat_message(message["role"]): st.markdown(message["content"]) Assistant
It seems like you're trying to implement a chatbot interface that can stream the conversation and keep all records. Here's a simplified way to achieve this using your given code snippets:
pythonimport streamlit as st # Initialize session state if it doesn't exist if "messages" not in st.session_state: st.session_state.messages = [] # Function to handle chat input and API request def process_chat_input(): user_input = st.chat_input("Say something") if user_input: st.session_state.messages.append({"role": "user", "content": user_input}) api_output = request_completion(url_input, api_key_input, user_input, parameters, True) st.session_state.messages.append({"role": "assistant", "content": api_output}) # Streamlit chat interface chatbox = st.chat(process_chat_input) # Display chat history for message in st.session_state.messages: with chatbox.chat_message(message["role"]): st.markdown(message["content"])
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.