Solshine commited on
Commit
a7d6776
1 Parent(s): 3489c0f

Reverted back

Browse files
Files changed (1) hide show
  1. query.py +13 -13
query.py CHANGED
@@ -13,7 +13,7 @@ class VectaraQuery():
13
  self.customer_id = customer_id
14
  self.corpus_ids = corpus_ids
15
  self.api_key = api_key
16
- self.conv_id = "1dc2c542-925f-4b48-aab5-e3df6f2a3a64"
17
 
18
  def submit_query(self, query_str: str):
19
  corpora_key_list = [{
@@ -80,18 +80,18 @@ class VectaraQuery():
80
  docs = res['responseSet'][0]['document']
81
  chat = res['responseSet'][0]['summary'][0]['chat']
82
 
83
- # if chat['status'] != None:
84
- # # chat['status'] = # I have no idea what to put here hahaha
85
- # st_code = chat['status']
86
- # print(f"Chat query failed with code {st_code}")
87
- # if st_code == 'RESOURCE_EXHAUSTED':
88
- # self.conv_id = None
89
- # return 'Sorry, chat turns exceeds plan limit.'
90
- # return 'Sorry, something went wrong in my brain. Please try again later.'
91
-
92
- self.conv_id = res['responseSet'][0]['summary'][0]['chat']["1dc2c542-925f-4b48-aab5-e3df6f2a3a64"]
93
- print("BIG CHANGE")
94
-
95
 
96
  pattern = r'\[\d{1,2}\]'
97
  matches = [match.span() for match in re.finditer(pattern, summary)]
 
13
  self.customer_id = customer_id
14
  self.corpus_ids = corpus_ids
15
  self.api_key = api_key
16
+ self.conv_id = None
17
 
18
  def submit_query(self, query_str: str):
19
  corpora_key_list = [{
 
80
  docs = res['responseSet'][0]['document']
81
  chat = res['responseSet'][0]['summary'][0]['chat']
82
 
83
+ if chat['status'] != None:
84
+ st_code = chat['status']
85
+ print(f"Chat query failed with code {st_code}")
86
+ if st_code == 'RESOURCE_EXHAUSTED':
87
+ self.conv_id = None
88
+ return 'Sorry, Vectara 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
+ else:
94
+ print("I'm sorry. I am experiencing an error in Vectara API conversationId assignment")
95
 
96
  pattern = r'\[\d{1,2}\]'
97
  matches = [match.span() for match in re.finditer(pattern, summary)]