-
Notifications
You must be signed in to change notification settings - Fork 0
/
chatPDF_OpenAI.py
27 lines (19 loc) · 1021 Bytes
/
chatPDF_OpenAI.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from RAG.storing import store_VectorDB
from RAG.loading import load_VectorDB
from RAG.query import query_engine
import os
# Constants
pdf_file_path = ("Source_Documents/A Comprehensive Survey of Hallucination Mitigation Techniques in Large Language "
"Models.pdf")
prompt = "What are the various hallucination mitigation techniques in Large language Models"
os.environ["OPENAI_API_KEY"] = "Type your API here"
if __name__ == "__main__":
"""Please change the model in model.py and make sure to change your API key above"""
data_availalble = True
pcr = True # Try the parent child chunk retrieval. Not good results to be honest
if data_availalble:
vector_index, service_context, base_nodes = load_VectorDB() # Need to remove base_nodes which means no need to re-read the file again.
else:
vector_index, service_context, base_nodes = store_VectorDB(pdf_file_path)
response = query_engine(vector_index, base_nodes, service_context, prompt)
print(response)