Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -35,11 +35,11 @@ def load_pdf_and_generate_embeddings(pdf_doc, open_ai_key):
|
|
35 |
Return the key fields from the question followed by : and the answer :"""
|
36 |
PROMPT = PromptTemplate(template=prompt_template, input_variables=["context", "question"])
|
37 |
chain_type_kwargs = {"prompt": PROMPT}
|
38 |
-
pdf_qa = RetrievalQA.from_chain_type(llm=ChatOpenAI(temperature=0, model_name="gpt-4"),chain_type="stuff", retriever=vectordb.as_retriever(), chain_type_kwargs=chain_type_kwargs, return_source_documents=False)
|
39 |
|
40 |
return "Ready"
|
41 |
else:
|
42 |
-
return "Please provide an OpenAI API key"
|
43 |
|
44 |
|
45 |
def answer_predefined_questions(document_type):
|
@@ -63,11 +63,11 @@ def answer_predefined_questions(document_type):
|
|
63 |
field1 = "Borrower"
|
64 |
query2 = "what is the Property Address?"
|
65 |
field2 = "Property Address"
|
66 |
-
query3 = "what is the
|
67 |
field3 = "Loan Term"
|
68 |
-
query4 = "What is the
|
69 |
field4 = "Base Income"
|
70 |
-
query5 = "what is the
|
71 |
field5 = "Borrower SSN"
|
72 |
|
73 |
else:
|
@@ -99,8 +99,8 @@ css="""
|
|
99 |
title = """
|
100 |
<div style="text-align: center;max-width: 700px;">
|
101 |
<h1>Chatbot for PDFs - GPT-4</h1>
|
102 |
-
<p style="text-align: center;">Upload a .PDF, click the "
|
103 |
-
Wait for the Status to show Ready
|
104 |
The app is built on GPT-4 and leverages PromptTemplate</p>
|
105 |
</div>
|
106 |
"""
|
|
|
35 |
Return the key fields from the question followed by : and the answer :"""
|
36 |
PROMPT = PromptTemplate(template=prompt_template, input_variables=["context", "question"])
|
37 |
chain_type_kwargs = {"prompt": PROMPT}
|
38 |
+
pdf_qa = RetrievalQA.from_chain_type(llm=ChatOpenAI(temperature=0, model_name="gpt-4"),chain_type="stuff", retriever=vectordb.as_retriever(search_kwargs={"k": 5}), chain_type_kwargs=chain_type_kwargs, return_source_documents=False)
|
39 |
|
40 |
return "Ready"
|
41 |
else:
|
42 |
+
return "Please provide an OpenAI gpt-4 API key"
|
43 |
|
44 |
|
45 |
def answer_predefined_questions(document_type):
|
|
|
63 |
field1 = "Borrower"
|
64 |
query2 = "what is the Property Address?"
|
65 |
field2 = "Property Address"
|
66 |
+
query3 = "what is the Loan Term?"
|
67 |
field3 = "Loan Term"
|
68 |
+
query4 = "What is the Base Income?"
|
69 |
field4 = "Base Income"
|
70 |
+
query5 = "what is the Borrower's SSN?"
|
71 |
field5 = "Borrower SSN"
|
72 |
|
73 |
else:
|
|
|
99 |
title = """
|
100 |
<div style="text-align: center;max-width: 700px;">
|
101 |
<h1>Chatbot for PDFs - GPT-4</h1>
|
102 |
+
<p style="text-align: center;">Upload a .PDF, click the "Upload PDF and generate embeddings" button, <br />
|
103 |
+
Wait for the Status to show Ready. You can chose to get answers to the pre-defined question set OR ask your own question <br />
|
104 |
The app is built on GPT-4 and leverages PromptTemplate</p>
|
105 |
</div>
|
106 |
"""
|