sonoisa commited on
Commit
1124071
1 Parent(s): f52a01f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -178,9 +178,10 @@ if search_buttion or prev_query != str(query_input):
178
  results = zip(range(len(distances)), distances)
179
  results = sorted(results, key=lambda x: x[1])
180
 
181
- for idx, distance in results[0:closest_n]:
182
- # print(sentences[idx].strip(), "(Score: %.4f)" % (distance / 2))
183
- st.markdown(
184
- f"[%.4f {df.iloc[idx]['title']}]({df.iloc[idx]['page']})"
185
- % (distance / 2)
186
- )
 
 
178
  results = zip(range(len(distances)), distances)
179
  results = sorted(results, key=lambda x: x[1])
180
 
181
+ for i, (idx, distance) in enumerate(results[0:closest_n]):
182
+ md_content = ""
183
+ page_url = df.iloc[idx]["page"]
184
+ for img in df.iloc[idx]["imgs"]:
185
+ md_content += f'<a href="{page_url}" target="_blank" rel="noopener noreferrer"><img src="{img}" width="100"></a>'
186
+ md_content += f'\n[%.4f {df.iloc[idx]["title"]}]({page_url})' % (distance / 2)
187
+ st.markdown(md_content, unsafe_allow_html=True)