File size: 968 Bytes
d22b8ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e95e0c3
d22b8ea
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import streamlit as st
import random


st.title("💬 Juoksuta AI: R&D LAB")

col1, col2 = st.columns(2)

with col1:
	if st.button('Tulosta viestiketju.'):
	    print(st.session_state)
   
with col2:
	if st.button('Tyhjennä viestiketju'):
	    for key in st.session_state.keys():
	    	del st.session_state[key]

if "messages" not in st.session_state:
    st.session_state["messages"] = [{"role": "assistant", "content": "Miten voin auttaa?"}]

for msg in st.session_state.messages:
    st.chat_message(msg["role"]).write(msg["content"])

msg_bank = ["Aurinko paistaa", "Kuu loistaa", "Tietokone pörisee", "Mehu on hyvää"]

if prompt := st.chat_input("Kirjoita tähän."):
   
 
    st.session_state.messages.append({"role": "user", "content": prompt})
    st.chat_message("user").write(prompt)
    
    msg = random.choice(msg_bank)
    
    st.session_state.messages.append({"role": "assistant", "content": msg})
    st.chat_message("assistant").write(msg)