Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -11,49 +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 |
-
#
|
15 |
-
|
16 |
-
|
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 |
-
|
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 |
-
|
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
|
@@ -61,15 +34,6 @@ except: # catch exception and set query param to predefined value
|
|
61 |
#if 'query' not in st.session_state:
|
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()
|
@@ -82,6 +46,44 @@ except: # catch exception and set query param to predefined value
|
|
82 |
|
83 |
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
DEVICE = "cpu"
|
87 |
MODEL_OPTIONS = ["msmarco-distilbert-base-tas-b", "all-mpnet-base-v2"]
|
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")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
try:
|
18 |
+
st.experimental_set_query_params(option=st.session_state.query)
|
|
|
19 |
except ValueError:
|
20 |
pass
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# check if here for the first time then set the query
|
23 |
if 'query' not in st.session_state:
|
24 |
+
st.session_state['query'] = 'AI'
|
25 |
query = st.text_input("", value="AI", key="query")
|
26 |
st.session_state.query = 'AI'
|
27 |
st.write(st.session_state.query)
|
28 |
else:
|
29 |
query = st.text_input("", value=st.session_state["query"], key="query")
|
|
|
30 |
try:
|
31 |
st.session_state.query = query # if set already above. this prevents two interface elements setting it first time once
|
32 |
except: # catch exception and set query param to predefined value
|
34 |
#if 'query' not in st.session_state:
|
35 |
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
# Text Input, check the query params set the text input to query value if in session
|
38 |
try:
|
39 |
query_params = st.experimental_get_query_params()
|
46 |
|
47 |
|
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"]
|
51 |
+
query_params = st.experimental_get_query_params()
|
52 |
+
ix = 0
|
53 |
+
if query_params:
|
54 |
+
try:
|
55 |
+
q0 = query_params['query'][0]
|
56 |
+
ix = options.index(q0)
|
57 |
+
except ValueError:
|
58 |
+
pass
|
59 |
+
selected_option = st.radio(
|
60 |
+
"Param", options, index=ix, key="query", on_change=update_params
|
61 |
+
)
|
62 |
+
st.experimental_set_query_params(option=selected_option)
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
|
67 |
+
|
68 |
+
# 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)
|
69 |
+
#@st.experimental_singleton
|
70 |
+
#def get_sessionmaker(search_param):
|
71 |
+
# url = "https://en.wikipedia.org/wiki/"
|
72 |
+
# return url
|
73 |
+
#search_param = "Star_Trek:_Discovery"
|
74 |
+
#sm= get_sessionmaker(search_param)
|
75 |
+
|
76 |
+
# 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."
|
77 |
+
#@st.experimental_memo
|
78 |
+
#def factorial(n):
|
79 |
+
# if n < 1:
|
80 |
+
# return 1
|
81 |
+
# return n * factorial(n - 1)
|
82 |
+
#em10 = factorial(10)
|
83 |
+
#em09 = factorial(9) # Returns instantly!
|
84 |
+
|
85 |
+
|
86 |
+
|
87 |
|
88 |
DEVICE = "cpu"
|
89 |
MODEL_OPTIONS = ["msmarco-distilbert-base-tas-b", "all-mpnet-base-v2"]
|