awacke1 commited on
Commit
221071c
β€’
1 Parent(s): 55d4182

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -34
app.py CHANGED
@@ -12,34 +12,48 @@ from st_click_detector import click_detector
12
  # This lil dealio is my test of the new experiemntal primitives which promise to put cach in streamlit within striking distance of simulating cognitive episodic memory (personalized feelings about a moment through space time), and semantic memory (factual memories we are ready to share and communicate like your email address or physical address yo
13
 
14
  # What impresses me about these two beautiful new streamlit persist prims is that one called the singleton can share memory across sessions (think all users yo)
15
- @st.experimental_singleton
16
- def get_sessionmaker(search_param):
17
- url = "https://en.wikipedia.org/wiki/"
18
- return url
19
- search_param = "Star_Trek:_Discovery"
20
- sm= get_sessionmaker(search_param)
21
-
22
-
23
 
24
  # What is supercool about the second prim the memo is it makes unwieldy data very wieldy. Like the Lord of Rings in reverse re "you cannot wield it! none of us can." -> "You can wield it, now everyone can."
25
- @st.experimental_memo
26
- def factorial(n):
27
- if n < 1:
28
- return 1
29
- return n * factorial(n - 1)
30
  #em10 = factorial(10)
31
  #em09 = factorial(9) # Returns instantly!
32
 
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  # check if here for the first time then set the query
36
  if 'query' not in st.session_state:
37
  #st.session_state['query'] = 'value'
38
- query = st.text_input("", value="artificial intelligence", key="query")
39
- #st.session_state.query = 'Genomics'
40
  st.write(st.session_state.query)
41
  else:
42
  query = st.text_input("", value=st.session_state["query"], key="query")
 
43
  try:
44
  st.session_state.query = query # if set already above. this prevents two interface elements setting it first time once
45
  except: # catch exception and set query param to predefined value
@@ -48,31 +62,14 @@ except: # catch exception and set query param to predefined value
48
 
49
 
50
  # callback to update query param on selectbox change
51
- def update_params():
52
- print("update1")
53
  #try:
54
  #st.experimental_set_query_params(option=st.session_state.query)
55
  #except ValueError:
56
  # pass
57
 
58
 
59
- # radio button persistance - plan is to hydrate when selected and change url along with textbox and search
60
- options = ["ai", "nlp", "iot", "vr", "genomics", "graph", "cognitive"]
61
- query_params = st.experimental_get_query_params()
62
- # set selectbox value based on query param, or provide a default
63
- ix = 0
64
- if query_params:
65
- try:
66
- q0 = query_params['query'][0]
67
- ix = options.index(q0)
68
- except ValueError:
69
- pass
70
- selected_option = st.radio(
71
- "Param", options, index=ix, key="query", on_change=update_params
72
- )
73
- # set query param based on selection
74
- st.experimental_set_query_params(option=selected_option)
75
-
76
  # Text Input, check the query params set the text input to query value if in session
77
  try:
78
  query_params = st.experimental_get_query_params()
12
  # This lil dealio is my test of the new experiemntal primitives which promise to put cach in streamlit within striking distance of simulating cognitive episodic memory (personalized feelings about a moment through space time), and semantic memory (factual memories we are ready to share and communicate like your email address or physical address yo
13
 
14
  # What impresses me about these two beautiful new streamlit persist prims is that one called the singleton can share memory across sessions (think all users yo)
15
+ #@st.experimental_singleton
16
+ #def get_sessionmaker(search_param):
17
+ # url = "https://en.wikipedia.org/wiki/"
18
+ # return url
19
+ #search_param = "Star_Trek:_Discovery"
20
+ #sm= get_sessionmaker(search_param)
 
 
21
 
22
  # What is supercool about the second prim the memo is it makes unwieldy data very wieldy. Like the Lord of Rings in reverse re "you cannot wield it! none of us can." -> "You can wield it, now everyone can."
23
+ #@st.experimental_memo
24
+ #def factorial(n):
25
+ # if n < 1:
26
+ # return 1
27
+ # return n * factorial(n - 1)
28
  #em10 = factorial(10)
29
  #em09 = factorial(9) # Returns instantly!
30
 
31
 
32
+ # radio button persistance - plan is to hydrate when selected and change url along with textbox and search
33
+ options = ["ai", "nlp", "iot", "vr", "genomics", "graph", "cognitive"]
34
+ query_params = st.experimental_get_query_params()
35
+ ix = 0
36
+ if query_params:
37
+ try:
38
+ q0 = query_params['query'][0]
39
+ ix = options.index(q0)
40
+ except ValueError:
41
+ pass
42
+ selected_option = st.radio(
43
+ "Param", options, index=ix, key="query", on_change=update_params
44
+ )
45
+ st.experimental_set_query_params(option=selected_option)
46
+
47
 
48
  # check if here for the first time then set the query
49
  if 'query' not in st.session_state:
50
  #st.session_state['query'] = 'value'
51
+ query = st.text_input("", value="AI", key="query")
52
+ st.session_state.query = 'AI'
53
  st.write(st.session_state.query)
54
  else:
55
  query = st.text_input("", value=st.session_state["query"], key="query")
56
+
57
  try:
58
  st.session_state.query = query # if set already above. this prevents two interface elements setting it first time once
59
  except: # catch exception and set query param to predefined value
62
 
63
 
64
  # callback to update query param on selectbox change
65
+ #def update_params():
66
+ # print("update1")
67
  #try:
68
  #st.experimental_set_query_params(option=st.session_state.query)
69
  #except ValueError:
70
  # pass
71
 
72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  # Text Input, check the query params set the text input to query value if in session
74
  try:
75
  query_params = st.experimental_get_query_params()