Spaces:
Sleeping
Sleeping
Add Language to Query Body
Browse files
query.py
CHANGED
@@ -10,7 +10,7 @@ class VectaraQuery():
|
|
10 |
self.conv_id = None
|
11 |
|
12 |
|
13 |
-
def get_body(self, query_str: str, stream: False):
|
14 |
corpora_list = [{
|
15 |
'corpus_key': corpus_key, 'lexical_interpolation': 0.005
|
16 |
} for corpus_key in self.corpus_keys
|
@@ -39,7 +39,7 @@ class VectaraQuery():
|
|
39 |
{
|
40 |
'prompt_name': self.prompt_name,
|
41 |
'max_used_search_results': 10,
|
42 |
-
'response_language':
|
43 |
'citations':
|
44 |
{
|
45 |
'style': 'none'
|
@@ -69,14 +69,14 @@ class VectaraQuery():
|
|
69 |
"grpc-timeout": "60S"
|
70 |
}
|
71 |
|
72 |
-
def submit_query(self, query_str: str):
|
73 |
|
74 |
if self.conv_id:
|
75 |
endpoint = f"https://api.vectara.io/v2/chats/{self.conv_id}/turns"
|
76 |
else:
|
77 |
endpoint = "https://api.vectara.io/v2/chats"
|
78 |
|
79 |
-
body = self.get_body(query_str, stream=False)
|
80 |
|
81 |
response = requests.post(endpoint, data=json.dumps(body), verify=True, headers=self.get_headers())
|
82 |
if response.status_code != 200:
|
@@ -101,14 +101,14 @@ class VectaraQuery():
|
|
101 |
|
102 |
return summary
|
103 |
|
104 |
-
def submit_query_streaming(self, query_str: str):
|
105 |
|
106 |
if self.conv_id:
|
107 |
endpoint = f"https://api.vectara.io/v2/chats/{self.conv_id}/turns"
|
108 |
else:
|
109 |
endpoint = "https://api.vectara.io/v2/chats"
|
110 |
|
111 |
-
body = self.get_body(query_str, stream=True)
|
112 |
|
113 |
response = requests.post(endpoint, data=json.dumps(body), verify=True, headers=self.get_stream_headers(), stream=True)
|
114 |
|
|
|
10 |
self.conv_id = None
|
11 |
|
12 |
|
13 |
+
def get_body(self, query_str: str, response_lang: str, stream: False):
|
14 |
corpora_list = [{
|
15 |
'corpus_key': corpus_key, 'lexical_interpolation': 0.005
|
16 |
} for corpus_key in self.corpus_keys
|
|
|
39 |
{
|
40 |
'prompt_name': self.prompt_name,
|
41 |
'max_used_search_results': 10,
|
42 |
+
'response_language': response_lang,
|
43 |
'citations':
|
44 |
{
|
45 |
'style': 'none'
|
|
|
69 |
"grpc-timeout": "60S"
|
70 |
}
|
71 |
|
72 |
+
def submit_query(self, query_str: str, language: str):
|
73 |
|
74 |
if self.conv_id:
|
75 |
endpoint = f"https://api.vectara.io/v2/chats/{self.conv_id}/turns"
|
76 |
else:
|
77 |
endpoint = "https://api.vectara.io/v2/chats"
|
78 |
|
79 |
+
body = self.get_body(query_str, language, stream=False)
|
80 |
|
81 |
response = requests.post(endpoint, data=json.dumps(body), verify=True, headers=self.get_headers())
|
82 |
if response.status_code != 200:
|
|
|
101 |
|
102 |
return summary
|
103 |
|
104 |
+
def submit_query_streaming(self, query_str: str, language: str):
|
105 |
|
106 |
if self.conv_id:
|
107 |
endpoint = f"https://api.vectara.io/v2/chats/{self.conv_id}/turns"
|
108 |
else:
|
109 |
endpoint = "https://api.vectara.io/v2/chats"
|
110 |
|
111 |
+
body = self.get_body(query_str, language, stream=True)
|
112 |
|
113 |
response = requests.post(endpoint, data=json.dumps(body), verify=True, headers=self.get_stream_headers(), stream=True)
|
114 |
|