import streamlit as st
from haystack.generator.transformers import RAGenerator
generator = RAGenerator(model_name_or_path="facebook/rag-token-nq",
                        embed_title=False, num_beams=5)

from haystack.pipeline import GenerativeQAPipeline
pipe = GenerativeQAPipeline(generator=generator, retriever=dpr_retriever)

def generate_answers(query, top_k_generator=3):
    preds = pipe.run(query=query, top_k_generator=top_k_generator,
                     top_k_retriever=5, filters={"item_id":["B0074BW614"]})
    st.write(f"Question: {preds['query']} \n")
    for idx in range(top_k_generator):
        st.write(f"Answer {idx+1}: {preds['answers'][idx]['answer']}")

query = st.textarea("Enter the Query:")
generate_answers(query)