ofermend commited on
Commit
f3b8910
1 Parent(s): 8d7a085

Update query.py

Browse files
Files changed (1) hide show
  1. query.py +3 -4
query.py CHANGED
@@ -123,9 +123,9 @@ class VectaraQuery():
123
  summary = res['responseSet'][0]['summary'][0]['text']
124
  responses = res['responseSet'][0]['response'][:top_k]
125
  docs = res['responseSet'][0]['document']
126
- chat = res['responseSet'][0]['summary'][0]['chat']
127
 
128
- if chat['status'] != None:
129
  st_code = chat['status']
130
  print(f"Chat query failed with code {st_code}")
131
  if st_code == 'RESOURCE_EXHAUSTED':
@@ -133,8 +133,7 @@ class VectaraQuery():
133
  return 'Sorry, Vectara chat turns exceeds plan limit.'
134
  return 'Sorry, something went wrong in my brain. Please try again later.'
135
 
136
- self.conv_id = res['responseSet'][0]['summary'][0]['chat']['conversationId']
137
-
138
  summary = CitationNormalizer().normalize_citations(summary, responses, docs)
139
  return summary
140
 
 
123
  summary = res['responseSet'][0]['summary'][0]['text']
124
  responses = res['responseSet'][0]['response'][:top_k]
125
  docs = res['responseSet'][0]['document']
126
+ chat = res['responseSet'][0]['summary'][0].get('chat', None)
127
 
128
+ if chat and chat['status'] is not None:
129
  st_code = chat['status']
130
  print(f"Chat query failed with code {st_code}")
131
  if st_code == 'RESOURCE_EXHAUSTED':
 
133
  return 'Sorry, Vectara chat turns exceeds plan limit.'
134
  return 'Sorry, something went wrong in my brain. Please try again later.'
135
 
136
+ self.conv_id = chat['conversationId'] if chat else None
 
137
  summary = CitationNormalizer().normalize_citations(summary, responses, docs)
138
  return summary
139