Chatbot-Arena-Leaderboard / streamlit_app.py
naruto169's picture
rename app.py to streamlit_app.py
45a69e0 verified
Raw
History Blame Contribute Delete
792 Bytes
import streamlit as st
st.title("Chatbot Demo")
# Initialize chat history
if "messages" not in st.session_state:
st.session_state.messages = []
# Display chat history
for message in st.session_state.messages:
with st.chat_message(message["role"]):
st.markdown(message["content"])
# Get user input
if prompt := st.chat_input("Type your message..."):
# Add user message to chat history
st.session_state.messages.append({"role": "user", "content": prompt})
with st.chat_message("user"):
st.markdown(prompt)
# Generate bot response (replace with your model logic)
response = f"You said: {prompt}"
st.session_state.messages.append({"role": "assistant", "content": response})
with st.chat_message("assistant"):
st.markdown(response)