Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,7 @@ import gradio as gr
|
|
4 |
from datetime import datetime
|
5 |
|
6 |
#Fill in your correct configuration
|
7 |
-
invoke_url = 'https://
|
8 |
bedrock_url = 'https://8hsh7fxan7.execute-api.us-west-2.amazonaws.com/prod'
|
9 |
|
10 |
|
@@ -239,6 +239,8 @@ def get_answer(task_type,question,sessionId,language,modelType,prompt,searchEngi
|
|
239 |
print("answer:",answer)
|
240 |
|
241 |
source_str = ""
|
|
|
|
|
242 |
for i in range(len(source_list)):
|
243 |
item = source_list[i]
|
244 |
print('item:',item)
|
@@ -252,19 +254,22 @@ def get_answer(task_type,question,sessionId,language,modelType,prompt,searchEngi
|
|
252 |
except KeyError:
|
253 |
source ="source:unknown"
|
254 |
print("KeyError:source file not found")
|
255 |
-
|
|
|
|
|
|
|
|
|
|
|
256 |
sentence = "sentence:" + item['sentence']
|
257 |
paragraph = "paragraph:" + item['paragraph']
|
258 |
-
|
|
|
259 |
# source_str += sentence + '\n'
|
260 |
source_str += paragraph + '\n\n'
|
261 |
|
262 |
confidence = ""
|
263 |
-
|
264 |
-
|
265 |
-
query_docs_score = float(result['scoreQueryDoc'])
|
266 |
-
if query_docs_score >= 0:
|
267 |
-
confidence += ("query_docs_score:" + str(query_docs_score) + '\n')
|
268 |
|
269 |
query_answer_score = -1
|
270 |
if 'scoreQueryAnswer' in result.keys():
|
@@ -273,12 +278,8 @@ def get_answer(task_type,question,sessionId,language,modelType,prompt,searchEngi
|
|
273 |
confidence += ("query_answer_score:" + str(query_answer_score) + '\n')
|
274 |
|
275 |
answer_docs_score = -1
|
276 |
-
if
|
277 |
-
answer_docs_score
|
278 |
-
if answer_docs_score >= 0:
|
279 |
-
confidence += ("answer_docs_score:" + str(answer_docs_score) + '\n')
|
280 |
-
|
281 |
-
|
282 |
|
283 |
return answer,confidence,source_str,url,request_time
|
284 |
|
|
|
4 |
from datetime import datetime
|
5 |
|
6 |
#Fill in your correct configuration
|
7 |
+
invoke_url = 'https://8pkry7xzo5.execute-api.us-west-2.amazonaws.com/prod'
|
8 |
bedrock_url = 'https://8hsh7fxan7.execute-api.us-west-2.amazonaws.com/prod'
|
9 |
|
10 |
|
|
|
239 |
print("answer:",answer)
|
240 |
|
241 |
source_str = ""
|
242 |
+
query_docs_score_list = []
|
243 |
+
answer_docs_score_list = []
|
244 |
for i in range(len(source_list)):
|
245 |
item = source_list[i]
|
246 |
print('item:',item)
|
|
|
254 |
except KeyError:
|
255 |
source ="source:unknown"
|
256 |
print("KeyError:source file not found")
|
257 |
+
qd_score = "qd score:" + str(item['scoreQueryDoc'])
|
258 |
+
query_docs_score_list.append(item['scoreQueryDoc'])
|
259 |
+
|
260 |
+
ad_score = "ad score:" + str(item['scoreAnswerDoc'])
|
261 |
+
answer_docs_score_list.append(item['scoreAnswerDoc'])
|
262 |
+
|
263 |
sentence = "sentence:" + item['sentence']
|
264 |
paragraph = "paragraph:" + item['paragraph']
|
265 |
+
|
266 |
+
source_str += (_id + " " + source + " " + qd_score + '\n')
|
267 |
# source_str += sentence + '\n'
|
268 |
source_str += paragraph + '\n\n'
|
269 |
|
270 |
confidence = ""
|
271 |
+
if len(query_docs_score_list) >= 0:
|
272 |
+
confidence += ("query_docs_score:" + str(query_docs_score_list) + '\n')
|
|
|
|
|
|
|
273 |
|
274 |
query_answer_score = -1
|
275 |
if 'scoreQueryAnswer' in result.keys():
|
|
|
278 |
confidence += ("query_answer_score:" + str(query_answer_score) + '\n')
|
279 |
|
280 |
answer_docs_score = -1
|
281 |
+
if len(answer_docs_score_list) >= 0:
|
282 |
+
confidence += ("answer_docs_score:" + str(answer_docs_score_list) + '\n')
|
|
|
|
|
|
|
|
|
283 |
|
284 |
return answer,confidence,source_str,url,request_time
|
285 |
|