Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -75,6 +75,9 @@ if 'counters' not in st.session_state:
|
|
75 |
if 'is_helpful' not in st.session_state:
|
76 |
st.session_state.is_helpful = {'ask':False}
|
77 |
|
|
|
|
|
|
|
78 |
# if 'model' not in st.session_state:
|
79 |
# st.session_state.model = {'model': False, 'tokenizer': False}
|
80 |
|
@@ -84,7 +87,7 @@ if 'is_helpful' not in st.session_state:
|
|
84 |
|
85 |
st.title("You name it!")
|
86 |
|
87 |
-
with st.chat_message('user'):
|
88 |
st.write("Hey assistant!")
|
89 |
|
90 |
bot = st.chat_message('assistant')
|
@@ -118,10 +121,13 @@ def write_bot(input, remember=True, blink=True):
|
|
118 |
def ask_if_helped():
|
119 |
y = st.button('Yes!', key=60)
|
120 |
n = st.button('No...', key=61)
|
|
|
121 |
if y:
|
122 |
write_bot("I am happy to help!")
|
123 |
elif n:
|
124 |
st.session_state.actions.append('cue')
|
|
|
|
|
125 |
# st.session_state.is_helpful['ask'] = False
|
126 |
|
127 |
if st.session_state.actions[-1] == "result":
|
@@ -181,21 +187,28 @@ if st.session_state.actions[-1] == 'cue':
|
|
181 |
#display user message in chat message container
|
182 |
prompt = get_text()
|
183 |
if prompt:
|
184 |
-
with st.chat_message('user'):
|
185 |
st.markdown(prompt)
|
186 |
#add to history
|
187 |
st.session_state.messages.append({'role': 'user', 'content': prompt})
|
188 |
-
yes = ['yes', 'again', 'Yes', 'sure']
|
189 |
if prompt in yes:
|
190 |
write_bot("Please describe your word!")
|
|
|
|
|
|
|
|
|
191 |
#if previously we asked to give a prompt
|
192 |
elif (st.session_state.messages[-2]['content'] == "Please describe your word!") & (st.session_state.messages[-1]['content'] != "no"):
|
193 |
write_bot("Great! Let me think what it could be...")
|
194 |
-
st.session_state.
|
|
|
195 |
st.session_state.results['results_print'] = dict(zip(range(1, 11), st.session_state.results['results']))
|
196 |
write_bot("I think I have some ideas. Do you want to see my guesses or do you want a cue?")
|
197 |
st.session_state.actions.append("result")
|
198 |
|
|
|
|
|
199 |
# elif prompt == 'results':
|
200 |
# st.text("results")
|
201 |
# st.write("results")
|
@@ -368,5 +381,4 @@ if prompt:
|
|
368 |
# st.write("I am sorry I couldn't help you. See you next time!")
|
369 |
# break
|
370 |
# else:
|
371 |
-
# st.write("I am happy I could be of help!")
|
372 |
-
|
|
|
75 |
if 'is_helpful' not in st.session_state:
|
76 |
st.session_state.is_helpful = {'ask':False}
|
77 |
|
78 |
+
if 'descriptions' not in st.session_state:
|
79 |
+
st.session_state.descriptions = []
|
80 |
+
|
81 |
# if 'model' not in st.session_state:
|
82 |
# st.session_state.model = {'model': False, 'tokenizer': False}
|
83 |
|
|
|
87 |
|
88 |
st.title("You name it!")
|
89 |
|
90 |
+
with st.chat_message('user', avatar='simon.jpg'):
|
91 |
st.write("Hey assistant!")
|
92 |
|
93 |
bot = st.chat_message('assistant')
|
|
|
121 |
def ask_if_helped():
|
122 |
y = st.button('Yes!', key=60)
|
123 |
n = st.button('No...', key=61)
|
124 |
+
new = st.button('I have a new word', key=62)
|
125 |
if y:
|
126 |
write_bot("I am happy to help!")
|
127 |
elif n:
|
128 |
st.session_state.actions.append('cue')
|
129 |
+
elif new:
|
130 |
+
write_bot("Please describe your word!")
|
131 |
# st.session_state.is_helpful['ask'] = False
|
132 |
|
133 |
if st.session_state.actions[-1] == "result":
|
|
|
187 |
#display user message in chat message container
|
188 |
prompt = get_text()
|
189 |
if prompt:
|
190 |
+
with st.chat_message('user', avatar='simon.jpg'):
|
191 |
st.markdown(prompt)
|
192 |
#add to history
|
193 |
st.session_state.messages.append({'role': 'user', 'content': prompt})
|
194 |
+
yes = ['yes', 'again', 'Yes', 'sure', 'new word', 'yes!']
|
195 |
if prompt in yes:
|
196 |
write_bot("Please describe your word!")
|
197 |
+
elif prompt == 'It is similar to the best place on earth':
|
198 |
+
write_bot("Great! Let me think what it could be...")
|
199 |
+
time.sleep(3)
|
200 |
+
write_bot("Do you mean Saarland?")
|
201 |
#if previously we asked to give a prompt
|
202 |
elif (st.session_state.messages[-2]['content'] == "Please describe your word!") & (st.session_state.messages[-1]['content'] != "no"):
|
203 |
write_bot("Great! Let me think what it could be...")
|
204 |
+
st.session_state.descriptions.append(prompt)
|
205 |
+
st.session_state.results['results'] = return_top_k(st.session_state.descriptions[-1])
|
206 |
st.session_state.results['results_print'] = dict(zip(range(1, 11), st.session_state.results['results']))
|
207 |
write_bot("I think I have some ideas. Do you want to see my guesses or do you want a cue?")
|
208 |
st.session_state.actions.append("result")
|
209 |
|
210 |
+
|
211 |
+
|
212 |
# elif prompt == 'results':
|
213 |
# st.text("results")
|
214 |
# st.write("results")
|
|
|
381 |
# st.write("I am sorry I couldn't help you. See you next time!")
|
382 |
# break
|
383 |
# else:
|
384 |
+
# st.write("I am happy I could be of help!")
|
|