omlakhani commited on
Commit
a203390
1 Parent(s): 6dc2f76

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +43 -13
app.py CHANGED
@@ -122,7 +122,7 @@ tools = [
122
  )
123
  ]
124
 
125
- prefix = "Give a detailed answer to the question"
126
  suffix = """Give answer intended for knowledgeable doctors
127
 
128
  Question: {input}
@@ -147,29 +147,59 @@ def get_answer(query_string):
147
  return result
148
 
149
 
150
- def get_answer2(list_thing):
151
  responses = []
152
- for question in list_thing:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  answer = get_answer(question)
154
  response = f"{question}\n{answer}"
155
- responses.append(response)
156
-
157
- return "\n\n".join(responses)
158
 
159
 
160
 
161
 
162
 
163
 
164
- def qa_app(query):
165
  question_list = generate_variations(query)
166
- big_answer = get_answer2(question_list)
167
- #final_answer = consolidated_answer(big_answer, query)
168
- return big_answer
169
-
 
 
 
 
 
 
 
 
170
 
171
- inputs = gr.inputs.Textbox(label="Enter your question:")
172
  output = gr.outputs.Textbox(label="Answer:")
173
- iface = gr.Interface(fn=qa_app, inputs=inputs, outputs=output, title="Endo AI : Endocrine answering app by Dr. Om J Lakhani")
 
 
 
 
 
 
174
 
175
  iface.launch()
 
 
122
  )
123
  ]
124
 
125
+ prefix = "Give an answer to the question"
126
  suffix = """Give answer intended for knowledgeable doctors
127
 
128
  Question: {input}
 
147
  return result
148
 
149
 
150
+ def get_answer2(list_thing, answer_type):
151
  responses = []
152
+ if answer_type == "Detailed Answer":
153
+ for question in list_thing:
154
+ answer = get_answer(question)
155
+ response = f"{question}\n{answer}"
156
+ responses.append(response)
157
+
158
+ return "\n\n".join(responses)
159
+ elif answer_type == "Consolidated answer":
160
+ for question in list_thing:
161
+ answer = get_answer(question)
162
+ response = f"{question}\n{answer}"
163
+ responses.append(response)
164
+
165
+ return "\n\n".join(responses)
166
+
167
+ else:
168
+ question = list_thing[0]
169
  answer = get_answer(question)
170
  response = f"{question}\n{answer}"
171
+ return response
172
+
173
+
174
 
175
 
176
 
177
 
178
 
179
 
180
+ def qa_app(query, answer_type):
181
  question_list = generate_variations(query)
182
+ big_answer = get_answer2(question_list, answer_type)
183
+ if answer_type == "Consolidated answer":
184
+ final_answer = consolidated_answer(big_answer, query)
185
+ return final_answer
186
+ else:
187
+ return big_answer
188
+
189
+
190
+ inputs = [
191
+ gr.inputs.Textbox(label="Enter your question:"),
192
+ gr.inputs.Dropdown(choices=["Quick Answer", "Detailed Answer", "Consolidated answer"], label="Choose answer type:")
193
+ ]
194
 
 
195
  output = gr.outputs.Textbox(label="Answer:")
196
+
197
+ iface = gr.Interface(
198
+ fn=qa_app,
199
+ inputs=inputs,
200
+ outputs=output,
201
+ title="Endo AI : Endocrine answering app by Dr. Om J Lakhani"
202
+ )
203
 
204
  iface.launch()
205
+