lekkalar commited on
Commit
551a0c0
1 Parent(s): 7aaadbf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -54
app.py CHANGED
@@ -46,73 +46,51 @@ def answer_predefined_questions(document_type):
46
 
47
  if document_type == "Deed of Trust":
48
  #Create a list of questions around the relevant fields of a Deed of Trust(DOT) document
49
- query0 = "what is the Lender's Name?"
50
- field0 = "Lender"
51
  query1 = "what is the Loan Number?"
52
  field1 = "Loan Number"
53
-
54
- queryList = [query0, query1]
55
- fieldList= [field0, field1]
56
-
57
-
58
-
 
 
59
 
60
  elif document_type == "Transmittal Summary":
61
  #Create a list of questions around the relevant fields of a TRANSMITTAL SUMMARY document
62
- queryA0 = "who is the Borrower?"
63
- fieldA0 = "Borrower"
64
- queryA1 = "what is the Property Address?"
65
- fieldA1 = "Property Address"
66
- queryA2 = "who is the Co-Borrower?"
67
- fieldA2 = "Co-Borrower"
68
- queryA3 = "what is the loan term?"
69
- fieldA3 = "Loan Term"
70
- queryA4 = "What is the base income?"
71
- fieldA4 = "Base Income"
72
- queryA5 = "what is the original loan amount?"
73
- fieldA5 = "Original Loan Amount"
74
- queryA6 = "what is the Initial P&I Payment?"
75
- fieldA6 = "Initial P&I Payment"
76
- queryA7 = "what is the borrower's SSN?"
77
- fieldA7 = "Borrower SSN"
78
- queryA8 = "what is the co-borrower's SSN?"
79
- fieldA8 = "C0-Borrower SSN"
80
- queryA9 = "Number of units?"
81
- fieldA9 = "Number of units"
82
- queryA10 = "who is the seller?"
83
- fieldA10 = "Seller"
84
- queryA11 = "Document signed date?"
85
- fieldA11 = "Singed Date"
86
- queryList = [queryA0, queryA1]
87
- fieldList = [fieldA0, fieldA1]
88
 
89
  else:
90
  return "Please choose your Document Type"
91
 
92
-
93
- response=""
 
 
94
  i = 0
95
  while i < len(queryList):
96
  question = queryList[i]
97
- field = fieldList[i]
98
-
99
- fieldInfo = "Field Name:"+ field
100
- response += fieldInfo
101
- questionInfo = "; Question sent to gpt-4: "+ question
102
- response += questionInfo
103
- answer = pdf_qa.run(question)
104
- gptResponse = "; Response from gpt-4:"+ answer
105
- response += gptResponse
106
-
107
- return response
108
 
109
 
110
 
111
  def answer_query(query):
112
  question = query
113
- response = "Field Name: Location; Question sent to gpt-4: ", question, "Response from gpt-4:",pdf_qa.run(question)
114
- #return response
115
- return pd.DataFrame({"Field": ['Location'], "Question": ['what is the location'], "Answer": ['Coppell,TX']})
116
 
117
  css="""
118
  #col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
@@ -137,17 +115,17 @@ with gr.Blocks(css=css,theme=gr.themes.Monochrome()) as demo:
137
 
138
  with gr.Row():
139
  status = gr.Textbox(label="Status", placeholder="", interactive=False)
140
- load_pdf = gr.Button("Load PDF").style(full_width=False)
141
 
142
  with gr.Row():
143
  document_type = gr.Radio(['Deed of Trust', 'Transmittal Summary'], label="Select the Document Type")
144
- answers = gr.Textbox(label="Answers to Predefined Question set")
145
  answers_for_predefined_question_set = gr.Button("Get Answers to Pre-defined Question set").style(full_width=False)
146
 
147
  with gr.Row():
148
  input = gr.Textbox(label="Type in your question")
149
- output = gr.Dataframe(label="Answer")
150
- submit_query = gr.Button("Submit your own question").style(full_width=False)
151
 
152
 
153
  load_pdf.click(load_pdf_and_generate_embeddings, inputs=[pdf_doc, openai_key], outputs=status)
 
46
 
47
  if document_type == "Deed of Trust":
48
  #Create a list of questions around the relevant fields of a Deed of Trust(DOT) document
 
 
49
  query1 = "what is the Loan Number?"
50
  field1 = "Loan Number"
51
+ query2 = "who is the Borrower?"
52
+ field2 = "Borrower"
53
+ query3 = "who is the Co-Borrower?"
54
+ field3 = "Co-Borrower"
55
+ query4 = "what is the Mortgage Identification number?"
56
+ field4 = "MIN Number"
57
+ query5 = "On what date was the Deed of Trust signed?"
58
+ field5 = "Signed Date"
59
 
60
  elif document_type == "Transmittal Summary":
61
  #Create a list of questions around the relevant fields of a TRANSMITTAL SUMMARY document
62
+ query1 = "who is the Borrower?"
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:
74
  return "Please choose your Document Type"
75
 
76
+ queryList = [query1, query2, query3, query4, query5]
77
+ fieldList = [field1, field2, field3, field4, field5]
78
+ responseList =[]
79
+
80
  i = 0
81
  while i < len(queryList):
82
  question = queryList[i]
83
+ responseList[i] = pdf_qa.run(question)
84
+ i = i+1
85
+
86
+ return pd.DataFrame({"Field": [fieldList[0], fieldList[1], fieldList[2], fieldList[3], fieldList[4]], "Question to gpt-4": [queryList[0], queryList[1], queryList[2], queryList[3], queryList[4]], "Response from gpt-4": [responseList[0],responseList[1],responseList[2],responseList[3],responseList[4]]})
 
 
 
 
 
 
 
87
 
88
 
89
 
90
  def answer_query(query):
91
  question = query
92
+ return pdf_qa.run(question)
93
+
 
94
 
95
  css="""
96
  #col-container {max-width: 700px; margin-left: auto; margin-right: auto;}
 
115
 
116
  with gr.Row():
117
  status = gr.Textbox(label="Status", placeholder="", interactive=False)
118
+ load_pdf = gr.Button(label="Load PDF").style(full_width=False)
119
 
120
  with gr.Row():
121
  document_type = gr.Radio(['Deed of Trust', 'Transmittal Summary'], label="Select the Document Type")
122
+ answers = gr.Dataframe(label="Answers to Predefined Question set")
123
  answers_for_predefined_question_set = gr.Button("Get Answers to Pre-defined Question set").style(full_width=False)
124
 
125
  with gr.Row():
126
  input = gr.Textbox(label="Type in your question")
127
+ output = gr.Textbox(label="Answer")
128
+ submit_query = gr.Button(label="Submit your own question").style(full_width=False)
129
 
130
 
131
  load_pdf.click(load_pdf_and_generate_embeddings, inputs=[pdf_doc, openai_key], outputs=status)