MineAI_Interface / sampleApp.py
Logeswaransr's picture
Create sampleApp.py
f483191
raw
history blame
No virus
903 Bytes
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 21 22:17:43 2023
@author: Loges
"""
import streamlit as st
st.set_page_config(page_title='Sample Chatbot', layout='wide')
if 'messages' not in st.session_state:
st.session_state.messages=[]
st.subheader("Sample Chatbot")
for message in st.session_state.messages:
with st.chat_message(message['role']):
st.markdown(message['content'])
## messages element format: {'role':'user', 'content':'<user prompt>'}
if prompt:=st.chat_input("What is up!"):
with st.chat_message("user"):
st.markdown(prompt)
st.session_state.messages.append({
'role':'user',
'content': prompt})
response = f"Echo: {prompt}"
with st.chat_message("assistant"):
st.markdown(response)
st.session_state.messages.append({
'role':'assistant',
'content': response})