Spaces:
Sleeping
Sleeping
test refactor
Browse files
app.py
CHANGED
@@ -123,37 +123,37 @@ def retriever(query: str, selected_retriever: str):
|
|
123 |
placeholder.markdown(text + "▌")
|
124 |
placeholder.markdown(text)
|
125 |
|
126 |
-
|
127 |
-
|
128 |
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
|
142 |
-
|
143 |
-
|
144 |
|
145 |
-
|
146 |
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
|
156 |
-
|
157 |
|
158 |
with st.chat_message("assistant"):
|
159 |
placeholder = st.empty()
|
|
|
123 |
placeholder.markdown(text + "▌")
|
124 |
placeholder.markdown(text)
|
125 |
|
126 |
+
if retriever_endpoint == "None":
|
127 |
+
return ""
|
128 |
|
129 |
+
headers = {
|
130 |
+
'Content-Type': 'application/json',
|
131 |
+
}
|
132 |
|
133 |
+
json_data = {
|
134 |
+
'claim': query,
|
135 |
+
}
|
136 |
|
137 |
+
url = "http://18.227.0.215"
|
138 |
+
port = "8000"
|
139 |
+
response = requests.post(f'{url}:{port}/{retriever_endpoint}', headers=headers, json=json_data)
|
140 |
+
documents = response.json()["Documents"]
|
141 |
|
142 |
+
k = 3
|
143 |
+
topk_documents = documents[:k]
|
144 |
|
145 |
+
corpus = '\n\n'.join(topk_documents)
|
146 |
|
147 |
+
retrieved_document_titles = ""
|
148 |
+
for document in topk_documents:
|
149 |
+
try:
|
150 |
+
idx = document.lower().index("abstract:")
|
151 |
+
title = document[:idx].replace('\n', ' ')
|
152 |
+
retrieved_document_titles = retrieved_document_titles + title + ' ||| '
|
153 |
+
except:
|
154 |
+
retrieved_document_titles = retrieved_document_titles + document + ' ||| '
|
155 |
|
156 |
+
display_retrieved_documents = f"Retrieved Documents - ||| {retrieved_document_titles}"
|
157 |
|
158 |
with st.chat_message("assistant"):
|
159 |
placeholder = st.empty()
|