ofermend commited on
Commit
f26592e
1 Parent(s): d26ed68

Update query.py

Browse files
Files changed (1) hide show
  1. query.py +10 -3
query.py CHANGED
@@ -13,6 +13,7 @@ class VectaraQuery():
13
  self.customer_id = customer_id
14
  self.corpus_ids = corpus_ids
15
  self.api_key = api_key
 
16
 
17
  def submit_query(self, query_str: str):
18
  corpora_key_list = [{
@@ -38,15 +39,19 @@ class VectaraQuery():
38
  'numResults': 7,
39
  'corpusKey': corpora_key_list,
40
  'context_config': {
41
- 'sentences_before': 3,
42
- 'sentences_after': 3,
43
  'start_tag': start_tag,
44
  'end_tag': end_tag,
45
  },
46
  'summary': [
47
  {
48
  'responseLang': 'eng',
49
- 'maxSummarizedResults': 7,
 
 
 
 
50
  }
51
  ]
52
  }
@@ -63,6 +68,7 @@ class VectaraQuery():
63
  summary = res['responseSet'][0]['summary'][0]['text']
64
  responses = res['responseSet'][0]['response']
65
  docs = res['responseSet'][0]['document']
 
66
  pattern = r'\[\d{1,2}\]'
67
  matches = [match.span() for match in re.finditer(pattern, summary)]
68
 
@@ -89,4 +95,5 @@ class VectaraQuery():
89
  url = f"{metadata['url']}#:~:text={quote(text)}"
90
  citation_inx = refs_dict[url]
91
  summary = summary[:start] + f'[\[{citation_inx}\]]({url})' + summary[end:]
 
92
  return 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 = [{
 
39
  'numResults': 7,
40
  'corpusKey': corpora_key_list,
41
  'context_config': {
42
+ 'sentences_before': 2,
43
+ 'sentences_after': 2,
44
  'start_tag': start_tag,
45
  'end_tag': end_tag,
46
  },
47
  'summary': [
48
  {
49
  'responseLang': 'eng',
50
+ 'maxSummarizedResults': 5,
51
+ 'chat': {
52
+ 'store': True,
53
+ 'conversationId': self.conv_id
54
+ }
55
  }
56
  ]
57
  }
 
68
  summary = res['responseSet'][0]['summary'][0]['text']
69
  responses = res['responseSet'][0]['response']
70
  docs = res['responseSet'][0]['document']
71
+ self.conv_id = summary[0]['chat']['conversationId']
72
  pattern = r'\[\d{1,2}\]'
73
  matches = [match.span() for match in re.finditer(pattern, summary)]
74
 
 
95
  url = f"{metadata['url']}#:~:text={quote(text)}"
96
  citation_inx = refs_dict[url]
97
  summary = summary[:start] + f'[\[{citation_inx}\]]({url})' + summary[end:]
98
+
99
  return summary