sonoisa commited on
Commit
f1bd711
โ€ข
1 Parent(s): 5cef811

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -159,13 +159,16 @@ df = pq.read_table("irasuto_items_20210224.parquet").to_pandas()
159
  sentence_vectors = np.stack(df["sentence_vector"])
160
 
161
  description_text.text("่ชฌๆ˜Žๆ–‡ใฎๆ„ๅ‘ณใŒ่ฟ‘ใ„ใ€Œใ„ใ‚‰ใ™ใจใ‚„ใ€็”ปๅƒใ‚’ๆคœ็ดขใ—ใพใ™ใ€‚")
 
 
162
  query_input = st.text_input(label="่ชฌๆ˜Žๆ–‡", value="")
163
  search_buttion = st.button("ๆคœ็ดข")
164
 
165
- closest_n = 5
166
 
167
- if search_buttion:
168
  query = str(query_input)
 
169
  query_embedding = model.encode([query]).numpy()
170
 
171
  distances = scipy.spatial.distance.cdist(
 
159
  sentence_vectors = np.stack(df["sentence_vector"])
160
 
161
  description_text.text("่ชฌๆ˜Žๆ–‡ใฎๆ„ๅ‘ณใŒ่ฟ‘ใ„ใ€Œใ„ใ‚‰ใ™ใจใ‚„ใ€็”ปๅƒใ‚’ๆคœ็ดขใ—ใพใ™ใ€‚")
162
+
163
+ prev_query = ""
164
  query_input = st.text_input(label="่ชฌๆ˜Žๆ–‡", value="")
165
  search_buttion = st.button("ๆคœ็ดข")
166
 
167
+ closest_n = 10
168
 
169
+ if search_buttion or prev_query != str(query_input):
170
  query = str(query_input)
171
+ prev_query = query
172
  query_embedding = model.encode([query]).numpy()
173
 
174
  distances = scipy.spatial.distance.cdist(