Spaces:
Runtime error
Runtime error
ivan-savchuk
commited on
Commit
β’
8362484
1
Parent(s):
24875d5
Update app.py
Browse files
app.py
CHANGED
@@ -59,11 +59,16 @@ if __name__ == "__main__":
|
|
59 |
)
|
60 |
# streamlit part starts here with title
|
61 |
st.title('Medical Search')
|
62 |
-
#
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
65 |
# on submit we execute search
|
66 |
-
if(
|
67 |
# set start time
|
68 |
stt = time.time()
|
69 |
# retrieve top 5 documents
|
@@ -72,23 +77,20 @@ if __name__ == "__main__":
|
|
72 |
ent = time.time()
|
73 |
# measure resulting time
|
74 |
elapsed_time = round(ent - stt, 2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
# define container for answers
|
77 |
-
with st.container():
|
78 |
-
st.empty()
|
79 |
-
# show which query was entered, and what was searching time
|
80 |
-
st.write(f'**Results Related to:** "{query}" ({elapsed_time} sec.)')
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
# answer starts with header
|
85 |
-
st.subheader(f"Answer {i+1}")
|
86 |
-
# cropped answer
|
87 |
-
doc = answer["doc"][:150] + "..."
|
88 |
-
# and url to the full answer
|
89 |
-
url = answer["url"]
|
90 |
-
# then we display it
|
91 |
-
st.markdown(f"{doc}\n[**Read More**]({url})\n")
|
92 |
-
|
93 |
-
st.markdown("---")
|
94 |
-
st.markdown("Author: Ivan Savchuk. 2022")
|
|
|
59 |
)
|
60 |
# streamlit part starts here with title
|
61 |
st.title('Medical Search')
|
62 |
+
# input form
|
63 |
+
with st.form("my_form"):
|
64 |
+
# here we have input space
|
65 |
+
query = st.text_input("Enter any query about our medical data",
|
66 |
+
placeholder="Type query here...")
|
67 |
+
# Every form must have a submit button.
|
68 |
+
submitted = st.form_submit_button("Search")
|
69 |
+
|
70 |
# on submit we execute search
|
71 |
+
if(submitted):
|
72 |
# set start time
|
73 |
stt = time.time()
|
74 |
# retrieve top 5 documents
|
|
|
77 |
ent = time.time()
|
78 |
# measure resulting time
|
79 |
elapsed_time = round(ent - stt, 2)
|
80 |
+
|
81 |
+
# show which query was entered, and what was searching time
|
82 |
+
st.write(f"**Results Related to:** {query} ({elapsed_time} sec.)")
|
83 |
+
# then we use loop to show results
|
84 |
+
for i, answer in enumerate([1, 2, 3, 4, 5]):
|
85 |
+
# answer starts with header
|
86 |
+
st.subheader(f"Answer {i+1}")
|
87 |
+
# cropped answer
|
88 |
+
doc = answer["doc"][:150] + "..."
|
89 |
+
# and url to the full answer
|
90 |
+
url = answer["url"]
|
91 |
+
# then we display it
|
92 |
+
st.markdown(f'{doc}\n[**Read More**]({url})\n', unsafe_allow_html=True)
|
93 |
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
+
st.markdown("---")
|
96 |
+
st.markdown("**Author:** Ivan Savchuk. 2022")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|