tareesh commited on
Commit
2ffe950
1 Parent(s): 5eaa4de

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from haystack.generator.transformers import RAGenerator
3
+ generator = RAGenerator(model_name_or_path="facebook/rag-token-nq",
4
+ embed_title=False, num_beams=5)
5
+
6
+ from haystack.pipeline import GenerativeQAPipeline
7
+ pipe = GenerativeQAPipeline(generator=generator, retriever=dpr_retriever)
8
+
9
+ def generate_answers(query, top_k_generator=3):
10
+ preds = pipe.run(query=query, top_k_generator=top_k_generator,
11
+ top_k_retriever=5, filters={"item_id":["B0074BW614"]})
12
+ st.write(f"Question: {preds['query']} \n")
13
+ for idx in range(top_k_generator):
14
+ st.write(f"Answer {idx+1}: {preds['answers'][idx]['answer']}")
15
+
16
+ query = st.textarea("Enter the Query:")
17
+ generate_answers(query)