Update query.py
Browse files
query.py
CHANGED
@@ -73,24 +73,24 @@ class VectaraQuery():
|
|
73 |
return "Sorry, something went wrong in my brain. Please try again later."
|
74 |
|
75 |
res = response.json()
|
76 |
-
print(f"DEBUG request body = {body}")
|
77 |
-
print(f"DEBUG response summary = {res['responseSet'][0]['summary']}")
|
78 |
-
|
79 |
-
st = res['responseSet'][0]['status']
|
80 |
-
if len(st)>0:
|
81 |
-
ecode = st[0].get('code','')
|
82 |
-
if ecode != '':
|
83 |
-
print(f"Chat query failed with code {ecode}")
|
84 |
-
if ecode == 'RESOURCE_EXHAUSTED':
|
85 |
-
self.conv_id = None
|
86 |
-
return 'Sorry, Vectara chat turns exceeds plan limit.'
|
87 |
-
return 'Sorry, something went wrong in my brain. Please try again later.'
|
88 |
-
|
89 |
|
90 |
top_k = 10
|
91 |
summary = res['responseSet'][0]['summary'][0]['text']
|
92 |
responses = res['responseSet'][0]['response'][:top_k]
|
93 |
docs = res['responseSet'][0]['document']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
self.conv_id = res['responseSet'][0]['summary'][0]['chat']['conversationId']
|
95 |
|
96 |
pattern = r'\[\d{1,2}\]'
|
|
|
73 |
return "Sorry, something went wrong in my brain. Please try again later."
|
74 |
|
75 |
res = response.json()
|
76 |
+
# print(f"DEBUG request body = {body}")
|
77 |
+
# print(f"DEBUG response summary = {res['responseSet'][0]['summary']}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
top_k = 10
|
80 |
summary = res['responseSet'][0]['summary'][0]['text']
|
81 |
responses = res['responseSet'][0]['response'][:top_k]
|
82 |
docs = res['responseSet'][0]['document']
|
83 |
+
chat = res['responseSet'][0]['summary'][0]['chat']
|
84 |
+
|
85 |
+
print(f"Chat = {chat}")
|
86 |
+
if chat['status'] != None:
|
87 |
+
st_code = chat['status']
|
88 |
+
print(f"Chat query failed with code {st_code}")
|
89 |
+
if st_code == 'RESOURCE_EXHAUSTED':
|
90 |
+
self.conv_id = None
|
91 |
+
return 'Sorry, Vectara chat turns exceeds plan limit.'
|
92 |
+
return 'Sorry, something went wrong in my brain. Please try again later.'
|
93 |
+
|
94 |
self.conv_id = res['responseSet'][0]['summary'][0]['chat']['conversationId']
|
95 |
|
96 |
pattern = r'\[\d{1,2}\]'
|