Spaces:
Sleeping
Sleeping
Update query.py
Browse files
query.py
CHANGED
|
@@ -81,6 +81,8 @@ class VectaraQuery():
|
|
| 81 |
response = requests.post(endpoint, data=json.dumps(body), verify=True, headers=self.get_headers())
|
| 82 |
if response.status_code != 200:
|
| 83 |
print(f"Query failed with code {response.status_code}, reason {response.reason}, text {response.text}")
|
|
|
|
|
|
|
| 84 |
return "Sorry, something went wrong in my brain. Please try again later."
|
| 85 |
|
| 86 |
res = response.json()
|
|
@@ -89,15 +91,6 @@ class VectaraQuery():
|
|
| 89 |
self.conv_id = res['chat_id']
|
| 90 |
|
| 91 |
summary = res['answer']
|
| 92 |
-
|
| 93 |
-
# FIGURE OUT HOW TO IMPLEMENT THIS IN APIV2
|
| 94 |
-
# if chat and chat['status'] is not None:
|
| 95 |
-
# st_code = chat['status']
|
| 96 |
-
# print(f"Chat query failed with code {st_code}")
|
| 97 |
-
# if st_code == 'RESOURCE_EXHAUSTED':
|
| 98 |
-
# self.conv_id = None
|
| 99 |
-
# return 'Sorry, Vectara chat turns exceeds plan limit.'
|
| 100 |
-
# return 'Sorry, something went wrong in my brain. Please try again later.'
|
| 101 |
|
| 102 |
return summary
|
| 103 |
|
|
|
|
| 81 |
response = requests.post(endpoint, data=json.dumps(body), verify=True, headers=self.get_headers())
|
| 82 |
if response.status_code != 200:
|
| 83 |
print(f"Query failed with code {response.status_code}, reason {response.reason}, text {response.text}")
|
| 84 |
+
if response.status_code == 429:
|
| 85 |
+
return "Sorry, Vectara chat turns exceeds plan limit."
|
| 86 |
return "Sorry, something went wrong in my brain. Please try again later."
|
| 87 |
|
| 88 |
res = response.json()
|
|
|
|
| 91 |
self.conv_id = res['chat_id']
|
| 92 |
|
| 93 |
summary = res['answer']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
return summary
|
| 96 |
|