Skip to content

Instantly share code, notes, and snippets.

@EnkrateiaLucca
Created October 3, 2023 16:09
Show Gist options
  • Save EnkrateiaLucca/578d9276bc422d5eb061ea5e29f12ec6 to your computer and use it in GitHub Desktop.
Save EnkrateiaLucca/578d9276bc422d5eb061ea5e29f12ec6 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
persist_directory = "./"
pdf = "./Mental_Links_to_Excellence.pdf"
loader = PyPDFLoader(pdf)
pdf_doc = loader.load_and_split()
embeddings = OpenAIEmbeddings()
vectordb = Chroma.from_documents(pdf_doc, embedding=embeddings,\
persist_directory=persist_directory)
vectordb.persist()
pdf_qa = ChatVectorDBChain.from_llm(OpenAI(temperature=0,\
model_name="gpt-4"), vectordb, return_source_documents=True)
query = "What are the habits of high performers?"
result = pdf_qa({"question": query, "chat_history": ""})
print("ANSWER")
print(result["answer"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment