ofermend commited on
Commit
89dffed
1 Parent(s): 5cff0d3

Update query.py

Browse files
Files changed (1) hide show
  1. query.py +9 -7
query.py CHANGED
@@ -76,13 +76,15 @@ class VectaraQuery():
76
  print(f"DEBUG request body = {body}")
77
  print(f"DEBUG response summary = {res['responseSet'][0]['summary']}")
78
 
79
- ecode = res['responseSet'][0]['status'][0].get('code','')
80
- if ecode != '':
81
- print(f"Chat query failed with code {ecode}")
82
- if ecode == 'RESOURCE_EXHAUSTED':
83
- self.conv_id = None
84
- return 'Sorry, Vectara chat turns exceeds plan limit.'
85
- return 'Sorry, something went wrong in my brain. Please try again later.'
 
 
86
 
87
 
88
  top_k = 10
 
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