Solshine commited on
Commit
af523d4
1 Parent(s): 2496807

Deleted bard drafted section and added a try else

Browse files
Files changed (1) hide show
  1. query.py +5 -19
query.py CHANGED
@@ -88,25 +88,11 @@ class VectaraQuery():
88
  # return 'Sorry, chat turns exceeds plan limit.'
89
  # return 'Sorry, something went wrong in my brain. Please try again later.'
90
 
91
- #from bard, of all places
92
- if res is not None and 'responseSet' in res and len(res['responseSet']) > 0:
93
- first_response = res['responseSet'][0]
94
- if 'summary' in first_response and len(first_response['summary']) > 0:
95
- first_summary = first_response['summary'][0]
96
- if 'chat' in first_summary:
97
- self.conv_id = res['responseSet'][0]['summary'][0]['chat']['conversationId']
98
- else:
99
- # Handle the case where 'chat' is None
100
- print("Chat data not found in response summary")
101
- else:
102
- # Handle the case where 'summary' is missing or empty
103
- print("Response summary missing or empty")
104
- else:
105
- # Handle the case where 'responseSet' is missing, empty, or 'res' is None
106
- print("Response data unavailable")
107
-
108
- #end of bard fix for none value error
109
-
110
  pattern = r'\[\d{1,2}\]'
111
  matches = [match.span() for match in re.finditer(pattern, summary)]
112
 
 
88
  # return 'Sorry, chat turns exceeds plan limit.'
89
  # return 'Sorry, something went wrong in my brain. Please try again later.'
90
 
91
+ try:
92
+ self.conv_id = res['responseSet'][0]['summary'][0]['chat']['conversationId']
93
+ except error:
94
+ return 'Sorry, something went wrong. Please try again later.'
95
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  pattern = r'\[\d{1,2}\]'
97
  matches = [match.span() for match in re.finditer(pattern, summary)]
98