sonoisa commited on
Commit
9c35bc0
โ€ข
1 Parent(s): 919c608

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -166,12 +166,17 @@ sentence_vectors = st.session_state.sentence_vectors
166
  description_text.text("่ชฌๆ˜Žๆ–‡ใฎๆ„ๅ‘ณใŒ่ฟ‘ใ„ใ€Œใ„ใ‚‰ใ™ใจใ‚„ใ€็”ปๅƒใ‚’ๆคœ็ดขใ—ใพใ™ใ€‚\nใ‚ญใƒผใƒฏใƒผใƒ‰ใ‚’ๅˆ—ๆŒ™ใ™ใ‚‹ใ‚ˆใ‚Šใ‚‚ใ€่‡ช็„ถใชๆ–‡็ซ ใ‚’ๅ…ฅๅŠ›ใ—ใŸๆ–นใŒ็ฒพๅบฆใ‚ˆใๆคœ็ดขใงใใพใ™ใ€‚")
167
 
168
  prev_query = ""
169
- query_input = st.text_input(label="่ชฌๆ˜Žๆ–‡", value="")
170
 
171
  closest_n = st.number_input(label="ๆคœ็ดขๆ•ฐ", min_value=1, value=10, max_value=100)
172
 
173
  search_buttion = st.button("ๆคœ็ดข")
174
 
 
 
 
 
 
175
  if search_buttion or prev_query != query_input:
176
  query = normalize_text(query_input)
177
  prev_query = query_input
@@ -190,4 +195,4 @@ if search_buttion or prev_query != query_input:
190
  for img_url in df.iloc[idx]["images"]:
191
  md_content += f'<a href="{page_url}" target="_blank" rel="noopener noreferrer"><img src="{img_url}" width="100"></a>'
192
  md_content += f'\n[{distance / 2:.4f}: {df.iloc[idx]["description"]}]({page_url})'
193
- st.markdown(md_content, unsafe_allow_html=True)
 
166
  description_text.text("่ชฌๆ˜Žๆ–‡ใฎๆ„ๅ‘ณใŒ่ฟ‘ใ„ใ€Œใ„ใ‚‰ใ™ใจใ‚„ใ€็”ปๅƒใ‚’ๆคœ็ดขใ—ใพใ™ใ€‚\nใ‚ญใƒผใƒฏใƒผใƒ‰ใ‚’ๅˆ—ๆŒ™ใ™ใ‚‹ใ‚ˆใ‚Šใ‚‚ใ€่‡ช็„ถใชๆ–‡็ซ ใ‚’ๅ…ฅๅŠ›ใ—ใŸๆ–นใŒ็ฒพๅบฆใ‚ˆใๆคœ็ดขใงใใพใ™ใ€‚")
167
 
168
  prev_query = ""
169
+ query_input = st.text_input(label="่ชฌๆ˜Žๆ–‡", value="", on_change=clear_result)
170
 
171
  closest_n = st.number_input(label="ๆคœ็ดขๆ•ฐ", min_value=1, value=10, max_value=100)
172
 
173
  search_buttion = st.button("ๆคœ็ดข")
174
 
175
+ result_text = st.empty()
176
+
177
+ def clear_result():
178
+ result_text.text("")
179
+
180
  if search_buttion or prev_query != query_input:
181
  query = normalize_text(query_input)
182
  prev_query = query_input
 
195
  for img_url in df.iloc[idx]["images"]:
196
  md_content += f'<a href="{page_url}" target="_blank" rel="noopener noreferrer"><img src="{img_url}" width="100"></a>'
197
  md_content += f'\n[{distance / 2:.4f}: {df.iloc[idx]["description"]}]({page_url})'
198
+ result_text.markdown(md_content, unsafe_allow_html=True)