awacke1 commited on
Commit
605b5ba
·
1 Parent(s): 3368b36

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +76 -0
app.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This streamlit demonstration is meant to simulate two types of memory within cognitive architecture:
2
+ # Each time we remember a moment, we construct it anew.
3
+ # We use the building blocks of Episodic Memory which is recall of feelings of being somewhere.
4
+ # We also use Semantic Memory which is concrete knowledge about our world and about our personal history.
5
+ # With Episodic Memory, its purpose is to provide us with coherence connecting events. In Episodic Memory, accuracy is less important than consistency.
6
+ # In order to have a strong sense of self, it is important that our memories fit with our beliefs and feelings about ourselves.
7
+
8
+ # Initialization
9
+ if 'key' not in st.session_state:
10
+ st.session_state['key'] = 'value'
11
+
12
+ # Session State also supports attribute based syntax
13
+ if 'key' not in st.session_state:
14
+ st.session_state.key = 'value'
15
+
16
+ # Read
17
+ st.write(st.session_state.key)
18
+
19
+ # Outputs: value
20
+
21
+ st.session_state.key = 'value2' # Attribute API
22
+ st.session_state['key'] = 'value2' # Dictionary like API
23
+
24
+ st.write(st.session_state)
25
+
26
+ # With magic:
27
+ st.session_state
28
+
29
+
30
+ st.write(st.session_state['value'])
31
+
32
+ # Throws an exception!
33
+
34
+ # Delete a single key-value pair
35
+ del st.session_state[key]
36
+
37
+ # Delete all the items in Session state
38
+ for key in st.session_state.keys():
39
+ del st.session_state[key]
40
+
41
+
42
+ st.text_input("Your name", key="name")
43
+
44
+ # This exists now:
45
+ st.session_state.name
46
+
47
+ def form_callback():
48
+ st.write(st.session_state.my_slider)
49
+ st.write(st.session_state.my_checkbox)
50
+
51
+ with st.form(key='my_form'):
52
+ slider_input = st.slider('My slider', 0, 10, 5, key='my_slider')
53
+ checkbox_input = st.checkbox('Yes or No', key='my_checkbox')
54
+ submit_button = st.form_submit_button(label='Submit', on_click=form_callback)
55
+
56
+ slider = st.slider(
57
+ label='My Slider', min_value=1,
58
+ max_value=10, value=5, key='my_slider')
59
+
60
+ st.session_state.my_slider = 7
61
+
62
+ # Throws an exception!
63
+
64
+ st.session_state.my_slider = 7
65
+
66
+ slider = st.slider(
67
+ label='Choose a Value', min_value=1,
68
+ max_value=10, value=5, key='my_slider')
69
+
70
+ if 'my_button' not in st.session_state:
71
+ st.session_state.my_button = True
72
+
73
+ st.button('My button', key='my_button')
74
+
75
+ # Throws an exception!
76
+