"""Ask a question to the notion database.""" import faiss from langchain import OpenAI from langchain.chains import VectorDBQAWithSourcesChain import pickle import argparse parser = argparse.ArgumentParser(description='Ask a question about the paper') parser.add_argument('question', type=str, help='The question to ask about the paper') args = parser.parse_args() # Load the LangChain. index = faiss.read_index("docs.index") with open("faiss_store.pkl", "rb") as f: store = pickle.load(f) store.index = index chain = VectorDBQAWithSourcesChain.from_llm(llm=OpenAI(temperature=0), vectorstore=store) result = chain({"question": args.question}) print(f"Answer: {result['answer']}") sources = result["sources"].split(", ") sources = [s.title() for s in sources] import code code.interact(local=locals())