File size: 2,290 Bytes
759c4c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import datetime
import time
import streamlit as st
import numpy as np


st.title("Streamlit App at Hugging Face Spaces!")
st.image("https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo-with-title.png")

with st.form("my_form"):
   st.write("Inside the form")
   slider_val = st.slider("Form slider")
   checkbox_val = st.checkbox("Form checkbox")

   # Every form must have a submit button.
   submitted = st.form_submit_button("Submit")
   if submitted:
       st.write("slider", slider_val, "checkbox", checkbox_val)

col1, col2, col3 = st.columns(3)

with col1:
   st.image("https://static.streamlit.io/examples/cat.jpg")

with col2:
   st.image("https://static.streamlit.io/examples/dog.jpg")

with col3:
   st.image("https://static.streamlit.io/examples/owl.jpg")

with st.sidebar:
    # st.image("https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.png")
    st.image("https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo-with-title.png")
    values = st.slider(
        'Select a range of values',
        0.0, 100.0, (25.0, 75.0))
    st.write('Values:', values)

    appointment = st.slider(
        "Schedule your appointment:",
        value=(datetime.time(11, 30), datetime.time(12, 45)))
    st.write("You're scheduled for:", appointment)

    start_time = st.slider(
        "When do you start?",
        value=datetime.datetime(2020, 1, 1, 9, 30),
        format="MM/DD/YY - hh:mm")
    st.write("Start time:", start_time)


if st.button('Three cheers'):
    st.toast('Hip!')
    time.sleep(.5)
    st.toast('Hip!')
    time.sleep(.5)
    st.toast('Hooray!', icon='🎉')


if "chat_messages" not in st.session_state:
    st.session_state.chat_messages = []

prompt = st.chat_input("Say something")
if prompt:
    st.session_state.chat_messages.append({"type": "user", "message": prompt})
    st.session_state.chat_messages.append({"type": "bot", "message": "Hello!", "chart": np.random.randn(30, 3)})

for message in st.session_state.chat_messages[::-1]:
    if message["type"] == "user":
        with st.chat_message("You"):
            st.write(message["message"])
    else:
        with st.chat_message("Bot"):
            st.write(message["message"])
            st.line_chart(message["chart"])