Tuana commited on
Commit
a10ed5c
·
1 Parent(s): 1f9c6ae

attemptint to parse answers

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
  from haystack.utils import fetch_archive_from_http, clean_wiki_text, convert_files_to_docs
 
3
  from haystack.document_stores import InMemoryDocumentStore
4
  from haystack.pipelines import ExtractiveQAPipeline
5
  from haystack.nodes import FARMReader, TfidfRetriever
@@ -27,9 +28,9 @@ load_and_write_data()
27
 
28
  def ask_question(question):
29
  prediction = pipeline.run(query=question, params={"Retriever": {"top_k": 10}, "Reader": {"top_k": 5}})
30
- st.write(prediction['answers'][0])
31
- st.write(prediction['answers'][1])
32
- st.write(prediction['answers'][2])
33
 
34
  if question:
35
  ask_question(question)
 
1
  import streamlit as st
2
  from haystack.utils import fetch_archive_from_http, clean_wiki_text, convert_files_to_docs
3
+ from haystack.schema import Answer
4
  from haystack.document_stores import InMemoryDocumentStore
5
  from haystack.pipelines import ExtractiveQAPipeline
6
  from haystack.nodes import FARMReader, TfidfRetriever
 
28
 
29
  def ask_question(question):
30
  prediction = pipeline.run(query=question, params={"Retriever": {"top_k": 10}, "Reader": {"top_k": 5}})
31
+ st.write(Answer(prediction['answers'][0]).to_dict())
32
+ st.write(Answer(prediction['answers'][1]).to_dict())
33
+ st.write(Answer(prediction['answers'][2]).to_dict())
34
 
35
  if question:
36
  ask_question(question)