Spaces:
Sleeping
Sleeping
xiaofeifei
commited on
Commit
•
71adf9e
1
Parent(s):
24011c4
Update app.py
Browse files
app.py
CHANGED
@@ -13,12 +13,11 @@
|
|
13 |
# See the License for the specific language governing permissions and
|
14 |
# limitations under the License.
|
15 |
|
|
|
|
|
16 |
from json import JSONDecodeError
|
17 |
import streamlit as st
|
18 |
from markdown import markdown
|
19 |
-
from utils import pipelines_files, pipelines_is_ready
|
20 |
-
import argparse
|
21 |
-
import os
|
22 |
from pipelines.document_stores import FAISSDocumentStore, MilvusDocumentStore
|
23 |
from pipelines.nodes import DensePassageRetriever, ErnieRanker
|
24 |
from pipelines.utils import (
|
@@ -266,15 +265,8 @@ def main():
|
|
266 |
|
267 |
st.session_state.random_question_requested = False
|
268 |
|
269 |
-
run_query = (
|
270 |
-
|
271 |
-
|
272 |
-
# Check the connection
|
273 |
-
with st.spinner("⌛️ pipelines is starting..."):
|
274 |
-
if not pipelines_is_ready():
|
275 |
-
st.error("🚫 Connection Error. Is pipelines running?")
|
276 |
-
run_query = False
|
277 |
-
reset_results()
|
278 |
# Get results for query
|
279 |
if (run_query or st.session_state.results is None) and question:
|
280 |
reset_results()
|
@@ -298,15 +290,6 @@ def main():
|
|
298 |
markdown(context),
|
299 |
unsafe_allow_html=True,
|
300 |
)
|
301 |
-
# Sqlalchemy Support storing list type data by adding value semicolon, so split str data into separate files
|
302 |
-
if type(result["images"]) == str:
|
303 |
-
result["images"] = result["images"].split(";")
|
304 |
-
for image_path in result["images"]:
|
305 |
-
image_url = pipelines_files(image_path)
|
306 |
-
st.image(
|
307 |
-
image_url,
|
308 |
-
width=400, # Manually Adjust the width of the image as per requirement
|
309 |
-
)
|
310 |
st.write("**Relevance:** ", result["relevance"])
|
311 |
|
312 |
st.write("___")
|
|
|
13 |
# See the License for the specific language governing permissions and
|
14 |
# limitations under the License.
|
15 |
|
16 |
+
import argparse
|
17 |
+
import os
|
18 |
from json import JSONDecodeError
|
19 |
import streamlit as st
|
20 |
from markdown import markdown
|
|
|
|
|
|
|
21 |
from pipelines.document_stores import FAISSDocumentStore, MilvusDocumentStore
|
22 |
from pipelines.nodes import DensePassageRetriever, ErnieRanker
|
23 |
from pipelines.utils import (
|
|
|
265 |
|
266 |
st.session_state.random_question_requested = False
|
267 |
|
268 |
+
run_query = ( run_pressed or question != st.session_state.question) and not st.session_state.random_question_requested
|
269 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
# Get results for query
|
271 |
if (run_query or st.session_state.results is None) and question:
|
272 |
reset_results()
|
|
|
290 |
markdown(context),
|
291 |
unsafe_allow_html=True,
|
292 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
st.write("**Relevance:** ", result["relevance"])
|
294 |
|
295 |
st.write("___")
|