Spaces:
Running
Running
new colors and images
Browse files- app.py +12 -3
- got-haystack.png +0 -0
app.py
CHANGED
@@ -7,8 +7,7 @@ from haystack.nodes import FARMReader, TfidfRetriever
|
|
7 |
import logging
|
8 |
from markdown import markdown
|
9 |
from annotated_text import annotation
|
10 |
-
import
|
11 |
-
import json
|
12 |
|
13 |
#Haystack Components
|
14 |
@st.cache(hash_funcs={"builtins.SwigPyObject": lambda _: None},allow_output_mutation=True)
|
@@ -42,6 +41,16 @@ def reset_results(*args):
|
|
42 |
#Streamlit App
|
43 |
|
44 |
st.title('Game of Thrones QA with Haystack')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
question = st.text_input("", value=st.session_state.question, max_chars=100, on_change=reset_results)
|
46 |
|
47 |
def ask_question(question):
|
@@ -87,7 +96,7 @@ if st.session_state.results:
|
|
87 |
start_idx = context.find(answer)
|
88 |
end_idx = start_idx + len(answer)
|
89 |
st.write(
|
90 |
-
markdown(context[:start_idx] + str(annotation(answer, "ANSWER", "#
|
91 |
unsafe_allow_html=True,
|
92 |
)
|
93 |
st.markdown(f"**Relevance:** {result['relevance']}")
|
|
|
7 |
import logging
|
8 |
from markdown import markdown
|
9 |
from annotated_text import annotation
|
10 |
+
from PIL import Image
|
|
|
11 |
|
12 |
#Haystack Components
|
13 |
@st.cache(hash_funcs={"builtins.SwigPyObject": lambda _: None},allow_output_mutation=True)
|
|
|
41 |
#Streamlit App
|
42 |
|
43 |
st.title('Game of Thrones QA with Haystack')
|
44 |
+
|
45 |
+
image = Image.open('got-haystack.png')
|
46 |
+
st.image(image)
|
47 |
+
|
48 |
+
st.markdown( """
|
49 |
+
This QA demo uses a [Haystack Extractive QA Pipleine](https://haystack.deepset.ai/components/ready-made-pipelines#extractiveqapipeline) with
|
50 |
+
an [InMemoryDocumentStore](https://haystack.deepset.ai/components/document-store) which contains documents about Game of Thrones 👑
|
51 |
+
Go ahead and ask questions about the marvelous kingdom!
|
52 |
+
""", unsafe_allow_html=True)
|
53 |
+
|
54 |
question = st.text_input("", value=st.session_state.question, max_chars=100, on_change=reset_results)
|
55 |
|
56 |
def ask_question(question):
|
|
|
96 |
start_idx = context.find(answer)
|
97 |
end_idx = start_idx + len(answer)
|
98 |
st.write(
|
99 |
+
markdown(context[:start_idx] + str(annotation(answer, "ANSWER", "#964448")) + context[end_idx:]),
|
100 |
unsafe_allow_html=True,
|
101 |
)
|
102 |
st.markdown(f"**Relevance:** {result['relevance']}")
|
got-haystack.png
ADDED