notSoNLPnerd commited on
Commit
7ab905d
1 Parent(s): 7f4540f

Added source information and modified sidebar text to include better component details

Browse files

Note: For the source, I am currently only showing up to the first 2000 chars of the document. I have tested it locally, and it generally covers the answer well.

Also, I was thinking that with the web-retriever, one can ask any question about recent news items. Should we make it more apparent in the description?

Files changed (2) hide show
  1. app.py +6 -0
  2. utils/ui.py +6 -10
app.py CHANGED
@@ -47,3 +47,9 @@ if st.session_state.get('query') and run_pressed:
47
  '\n This may take a few mins and might also fail if OpenAI API server is down.'):
48
  answers_2 = p3.run(ip)
49
  placeholder_retrieval_augmented.markdown(answers_2['results'][0])
 
 
 
 
 
 
 
47
  '\n This may take a few mins and might also fail if OpenAI API server is down.'):
48
  answers_2 = p3.run(ip)
49
  placeholder_retrieval_augmented.markdown(answers_2['results'][0])
50
+ print(answers_2['invocation_context']['documents'])
51
+ with st.expander("See source:"):
52
+ src = answers_2['invocation_context']['documents'][0].replace("$", "\$")
53
+ split_marker = "\n\n" if "\n\n" in src else "\n"
54
+ src = " ".join(src.split(split_marker))[0:2000] + "..."
55
+ st.write(src)
utils/ui.py CHANGED
@@ -34,7 +34,7 @@ def main_column():
34
  with placeholder:
35
  search_bar, button = st.columns([3, 1])
36
  with search_bar:
37
- username = st.text_area(f" ", max_chars=200, key='query')
38
 
39
  with button:
40
  st.write(" ")
@@ -44,11 +44,6 @@ def main_column():
44
  st.write(" ")
45
  st.radio("Answer Type:", (BUTTON_LOCAL_RET_AUG, BUTTON_WEB_RET_AUG), key="query_type")
46
 
47
- # st.sidebar.selectbox(
48
- # "Example Questions:",
49
- # QUERIES,
50
- # key='q_drop_down', on_change=set_question)
51
-
52
  st.markdown(f"<h5>{PLAIN_GPT_ANS}</h5>", unsafe_allow_html=True)
53
  placeholder_plain_gpt = st.empty()
54
  placeholder_plain_gpt.text_area(f" ", placeholder="The answer will appear here.", disabled=True,
@@ -80,7 +75,8 @@ def left_sidebar():
80
  image = Image.open('logo/haystack-logo-colored.png')
81
  st.markdown("Thanks for coming to this :hugging_face: space. \n\n"
82
  "This is an effort towards showcasing how you can use Haystack for Retrieval Augmented QA, "
83
- "with local document store and a WebRetriever (coming soon!). \n\n"
 
84
  "More information on how this was built and instructions along "
85
  "with a repository will be published soon and updated here.")
86
 
@@ -106,9 +102,9 @@ def left_sidebar():
106
  st.markdown(
107
  "## How this works\n"
108
  "This app was built with [Haystack](https://haystack.deepset.ai) using the"
109
- " [`PromptNode`](https://docs.haystack.deepset.ai/docs/prompt_node), "
110
- "[`Retriever`](https://docs.haystack.deepset.ai/docs/retriever#embedding-retrieval-recommended),"
111
- "and [`FAISSDocumentStore`](https://docs.haystack.deepset.ai/reference/document-store-api#faissdocumentstore).\n\n"
112
  " You can find the source code in **Files and versions** tab."
113
  )
114
 
 
34
  with placeholder:
35
  search_bar, button = st.columns([3, 1])
36
  with search_bar:
37
+ _ = st.text_area(f" ", max_chars=200, key='query')
38
 
39
  with button:
40
  st.write(" ")
 
44
  st.write(" ")
45
  st.radio("Answer Type:", (BUTTON_LOCAL_RET_AUG, BUTTON_WEB_RET_AUG), key="query_type")
46
 
 
 
 
 
 
47
  st.markdown(f"<h5>{PLAIN_GPT_ANS}</h5>", unsafe_allow_html=True)
48
  placeholder_plain_gpt = st.empty()
49
  placeholder_plain_gpt.text_area(f" ", placeholder="The answer will appear here.", disabled=True,
 
75
  image = Image.open('logo/haystack-logo-colored.png')
76
  st.markdown("Thanks for coming to this :hugging_face: space. \n\n"
77
  "This is an effort towards showcasing how you can use Haystack for Retrieval Augmented QA, "
78
+ "with local [FAISSDocumentStore](https://docs.haystack.deepset.ai/reference/document-store-api#faissdocumentstore)"
79
+ " or a [WebRetriever](https://docs.haystack.deepset.ai/docs/retriever#retrieval-from-the-web). \n\n"
80
  "More information on how this was built and instructions along "
81
  "with a repository will be published soon and updated here.")
82
 
 
102
  st.markdown(
103
  "## How this works\n"
104
  "This app was built with [Haystack](https://haystack.deepset.ai) using the"
105
+ " [PromptNode](https://docs.haystack.deepset.ai/docs/prompt_node), "
106
+ "[Retriever](https://docs.haystack.deepset.ai/docs/retriever#embedding-retrieval-recommended),"
107
+ "and [FAISSDocumentStore](https://docs.haystack.deepset.ai/reference/document-store-api#faissdocumentstore).\n\n"
108
  " You can find the source code in **Files and versions** tab."
109
  )
110