awacke1 commited on
Commit
88cc794
β€’
1 Parent(s): facbb76

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -30
app.py CHANGED
@@ -11,33 +11,22 @@ from st_click_detector import click_detector
11
 
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 prims is that one called the singleton can share memory across sessions (think all users yo)
15
-
16
  @st.experimental_singleton
17
  def get_sessionmaker(search_param):
18
- # This is for illustration purposes only
19
  url = "https://en.wikipedia.org/wiki/"
20
- #engine = create_engine(DB_URL)
21
- #return sessionmaker(engine)
22
  return url
23
-
24
  search_param = "Star_Trek:_Discovery"
25
  sm= get_sessionmaker(search_param)
26
- #print(sm)
27
 
28
  # 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."
29
-
30
  @st.experimental_memo
31
  def factorial(n):
32
  if n < 1:
33
  return 1
34
  return n * factorial(n - 1)
35
-
36
  #em10 = factorial(10)
37
- #print("em10:",em10)
38
  #em09 = factorial(9) # Returns instantly!
39
- #print("em09:",em09)
40
-
41
 
42
  # callback to update query param on selectbox change
43
  def update_params():
@@ -56,18 +45,6 @@ except: # catch exception and set query param to predefined value
56
  st.experimental_set_query_params(query="Genomics") # set default
57
  query_params = st.experimental_get_query_params()
58
  query_option = query_params['query'][0]
59
- if 'query' not in st.session_state:
60
- #st.session_state['query'] = 'value'
61
- query = st.text_input("", value="artificial intelligence", key="query")
62
- else:
63
- query = st.text_input("", value=st.session_state["query"], key="query")
64
- try:
65
- st.session_state.query = query # if set already above. this prevents two interface elements setting it first time once
66
- except: # catch exception and set query param to predefined value
67
- print("Error cant set after init")
68
- if 'query' not in st.session_state:
69
- st.session_state.query = 'Genomics'
70
- st.write(st.session_state.query)
71
 
72
  # radio button persistance - plan is to hydrate when selected and change url along with textbox and search
73
  options = ["ai", "nlp", "iot", "vr", "genomics", "graph", "cognitive"]
@@ -86,6 +63,19 @@ selected_option = st.radio(
86
  # set query param based on selection
87
  st.experimental_set_query_params(option=selected_option)
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
 
90
 
91
 
@@ -98,24 +88,19 @@ DESCRIPTION = """
98
  Built with πŸ€— Hugging Face's [transformers](https://huggingface.co/transformers/) library, [SentenceBert](https://www.sbert.net/) models, [Streamlit](https://streamlit.io/) and 44k movie descriptions from the Kaggle [Movies Dataset](https://www.kaggle.com/rounakbanik/the-movies-dataset)
99
  """
100
 
101
-
102
-
103
- # Session state
104
  if 'key' not in st.session_state:
105
  st.session_state['key'] = 'value'
106
  if 'key' not in st.session_state:
107
  st.session_state.key = 'value'
108
  st.write(st.session_state.key)
109
  st.write(st.session_state)
110
-
111
  #st.session_state
112
  for key in st.session_state.keys():
113
  del st.session_state[key]
114
  #st.text_input("Your name", key="name")
115
  #st.session_state.name
116
 
117
-
118
-
119
  @st.cache(
120
  show_spinner=False,
121
  hash_funcs={
 
11
 
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
  # callback to update query param on selectbox change
32
  def update_params():
 
45
  st.experimental_set_query_params(query="Genomics") # set default
46
  query_params = st.experimental_get_query_params()
47
  query_option = query_params['query'][0]
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  # radio button persistance - plan is to hydrate when selected and change url along with textbox and search
50
  options = ["ai", "nlp", "iot", "vr", "genomics", "graph", "cognitive"]
 
63
  # set query param based on selection
64
  st.experimental_set_query_params(option=selected_option)
65
 
66
+ # check if here for the first time then set the query
67
+ if 'query' not in st.session_state:
68
+ #st.session_state['query'] = 'value'
69
+ query = st.text_input("", value="artificial intelligence", key="query")
70
+ else:
71
+ query = st.text_input("", value=st.session_state["query"], key="query")
72
+ try:
73
+ st.session_state.query = query # if set already above. this prevents two interface elements setting it first time once
74
+ except: # catch exception and set query param to predefined value
75
+ print("Error cant set after init")
76
+ #if 'query' not in st.session_state:
77
+ # st.session_state.query = 'Genomics'
78
+ st.write(st.session_state.query)
79
 
80
 
81
 
 
88
  Built with πŸ€— Hugging Face's [transformers](https://huggingface.co/transformers/) library, [SentenceBert](https://www.sbert.net/) models, [Streamlit](https://streamlit.io/) and 44k movie descriptions from the Kaggle [Movies Dataset](https://www.kaggle.com/rounakbanik/the-movies-dataset)
89
  """
90
 
91
+ # Session state - search parms
 
 
92
  if 'key' not in st.session_state:
93
  st.session_state['key'] = 'value'
94
  if 'key' not in st.session_state:
95
  st.session_state.key = 'value'
96
  st.write(st.session_state.key)
97
  st.write(st.session_state)
 
98
  #st.session_state
99
  for key in st.session_state.keys():
100
  del st.session_state[key]
101
  #st.text_input("Your name", key="name")
102
  #st.session_state.name
103
 
 
 
104
  @st.cache(
105
  show_spinner=False,
106
  hash_funcs={