Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,6 +11,24 @@ 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 |
# callback to update query param on selectbox change
|
| 15 |
def update_params():
|
| 16 |
print("update1")
|
|
@@ -34,24 +52,6 @@ selected_option = st.radio(
|
|
| 34 |
"Param", options, index=ix, key="query", on_change=update_params
|
| 35 |
)
|
| 36 |
|
| 37 |
-
# check if here for the first time then set the query
|
| 38 |
-
if 'query' not in st.session_state:
|
| 39 |
-
#st.session_state['query'] = 'AI'
|
| 40 |
-
query = st.text_input("", value="AI", key="query")
|
| 41 |
-
#st.session_state.query = 'AI'
|
| 42 |
-
st.write(st.session_state.query)
|
| 43 |
-
else:
|
| 44 |
-
query = st.text_input("", value=st.session_state["query"], key="query")
|
| 45 |
-
|
| 46 |
-
try:
|
| 47 |
-
st.session_state.query = query # if set already above. this prevents two interface elements setting it first time once
|
| 48 |
-
except: # catch exception and set query param to predefined value
|
| 49 |
-
print("Error cant set after init")
|
| 50 |
-
#if 'query' not in st.session_state:
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
|
| 56 |
# Text Input, check the query params set the text input to query value if in session
|
| 57 |
try:
|
|
@@ -59,13 +59,12 @@ try:
|
|
| 59 |
query_option = query_params['query'][0] #throws an exception when visiting http://host:port
|
| 60 |
option_selected = st.sidebar.selectbox('Pick option', options, index=options.index(query_option))
|
| 61 |
except: # catch exception and set query param to predefined value
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
query_option = "ai"
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
|
| 70 |
# 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)
|
| 71 |
#@st.experimental_singleton
|
|
|
|
| 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 |
+
|
| 15 |
+
# check if here for the first time then set the query
|
| 16 |
+
if 'query' not in st.session_state:
|
| 17 |
+
st.session_state['query'] = 'AI'
|
| 18 |
+
query = st.text_input("", value="AI", key="query")
|
| 19 |
+
#st.session_state.query = 'AI'
|
| 20 |
+
st.write(st.session_state.query)
|
| 21 |
+
else:
|
| 22 |
+
query = st.text_input("", value=st.session_state["query"], key="query")
|
| 23 |
+
|
| 24 |
+
try:
|
| 25 |
+
st.session_state.query = query # if set already above. this prevents two interface elements setting it first time once
|
| 26 |
+
except: # catch exception and set query param to predefined value
|
| 27 |
+
print("Error cant set after init")
|
| 28 |
+
st.experimental_set_query_params(option=selected_option)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
# callback to update query param on selectbox change
|
| 33 |
def update_params():
|
| 34 |
print("update1")
|
|
|
|
| 52 |
"Param", options, index=ix, key="query", on_change=update_params
|
| 53 |
)
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
# Text Input, check the query params set the text input to query value if in session
|
| 57 |
try:
|
|
|
|
| 59 |
query_option = query_params['query'][0] #throws an exception when visiting http://host:port
|
| 60 |
option_selected = st.sidebar.selectbox('Pick option', options, index=options.index(query_option))
|
| 61 |
except: # catch exception and set query param to predefined value
|
| 62 |
+
st.experimental_set_query_params(query="Genomics") # set default
|
| 63 |
+
query_params = st.experimental_get_query_params()
|
| 64 |
+
query_option = query_params['query'][0]
|
| 65 |
query_option = "ai"
|
| 66 |
+
|
| 67 |
+
|
|
|
|
| 68 |
|
| 69 |
# 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)
|
| 70 |
#@st.experimental_singleton
|