usecortex-ai 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cortex_ai/__init__.py +103 -0
- cortex_ai/client.py +244 -0
- cortex_ai/core/__init__.py +52 -0
- cortex_ai/core/api_error.py +23 -0
- cortex_ai/core/client_wrapper.py +84 -0
- cortex_ai/core/datetime_utils.py +28 -0
- cortex_ai/core/file.py +67 -0
- cortex_ai/core/force_multipart.py +18 -0
- cortex_ai/core/http_client.py +543 -0
- cortex_ai/core/http_response.py +55 -0
- cortex_ai/core/jsonable_encoder.py +100 -0
- cortex_ai/core/pydantic_utilities.py +258 -0
- cortex_ai/core/query_encoder.py +58 -0
- cortex_ai/core/remove_none_from_dict.py +11 -0
- cortex_ai/core/request_options.py +35 -0
- cortex_ai/core/serialization.py +276 -0
- cortex_ai/embeddings/__init__.py +4 -0
- cortex_ai/embeddings/client.py +442 -0
- cortex_ai/embeddings/raw_client.py +1153 -0
- cortex_ai/environment.py +7 -0
- cortex_ai/errors/__init__.py +21 -0
- cortex_ai/errors/bad_request_error.py +11 -0
- cortex_ai/errors/forbidden_error.py +11 -0
- cortex_ai/errors/internal_server_error.py +11 -0
- cortex_ai/errors/not_found_error.py +11 -0
- cortex_ai/errors/service_unavailable_error.py +11 -0
- cortex_ai/errors/unauthorized_error.py +11 -0
- cortex_ai/errors/unprocessable_entity_error.py +10 -0
- cortex_ai/fetch/__init__.py +4 -0
- cortex_ai/fetch/client.py +143 -0
- cortex_ai/fetch/raw_client.py +310 -0
- cortex_ai/raw_client.py +90 -0
- cortex_ai/search/__init__.py +7 -0
- cortex_ai/search/client.py +536 -0
- cortex_ai/search/raw_client.py +1064 -0
- cortex_ai/search/types/__init__.py +7 -0
- cortex_ai/search/types/alpha.py +5 -0
- cortex_ai/sources/__init__.py +4 -0
- cortex_ai/sources/client.py +187 -0
- cortex_ai/sources/raw_client.py +532 -0
- cortex_ai/tenant/__init__.py +4 -0
- cortex_ai/tenant/client.py +120 -0
- cortex_ai/tenant/raw_client.py +283 -0
- cortex_ai/types/__init__.py +69 -0
- cortex_ai/types/actual_error_response.py +20 -0
- cortex_ai/types/app_sources_upload_data.py +22 -0
- cortex_ai/types/attachment_model.py +26 -0
- cortex_ai/types/batch_upload_data.py +22 -0
- cortex_ai/types/bm_25_operator_type.py +5 -0
- cortex_ai/types/content_model.py +26 -0
- cortex_ai/types/delete_memory_request.py +21 -0
- cortex_ai/types/embeddings_create_collection_data.py +22 -0
- cortex_ai/types/embeddings_delete_data.py +22 -0
- cortex_ai/types/embeddings_get_data.py +22 -0
- cortex_ai/types/embeddings_search_data.py +22 -0
- cortex_ai/types/error_response.py +22 -0
- cortex_ai/types/extended_context.py +20 -0
- cortex_ai/types/fetch_content_data.py +23 -0
- cortex_ai/types/file_upload_result.py +20 -0
- cortex_ai/types/full_text_search_data.py +22 -0
- cortex_ai/types/http_validation_error.py +20 -0
- cortex_ai/types/list_sources_response.py +22 -0
- cortex_ai/types/markdown_upload_request.py +21 -0
- cortex_ai/types/processing_status.py +22 -0
- cortex_ai/types/related_chunk.py +22 -0
- cortex_ai/types/search_chunk.py +34 -0
- cortex_ai/types/search_data.py +22 -0
- cortex_ai/types/single_upload_data.py +21 -0
- cortex_ai/types/source.py +32 -0
- cortex_ai/types/source_content.py +26 -0
- cortex_ai/types/source_model.py +32 -0
- cortex_ai/types/tenant_create_data.py +22 -0
- cortex_ai/types/tenant_stats.py +23 -0
- cortex_ai/types/validation_error.py +22 -0
- cortex_ai/types/validation_error_loc_item.py +5 -0
- cortex_ai/upload/__init__.py +4 -0
- cortex_ai/upload/client.py +1572 -0
- cortex_ai/upload/raw_client.py +4202 -0
- cortex_ai/user/__init__.py +4 -0
- cortex_ai/user/client.py +125 -0
- cortex_ai/user/raw_client.py +300 -0
- cortex_ai/user_memory/__init__.py +4 -0
- cortex_ai/user_memory/client.py +443 -0
- cortex_ai/user_memory/raw_client.py +651 -0
- usecortex_ai-0.1.0.dist-info/METADATA +136 -0
- usecortex_ai-0.1.0.dist-info/RECORD +89 -0
- usecortex_ai-0.1.0.dist-info/WHEEL +5 -0
- usecortex_ai-0.1.0.dist-info/licenses/LICENSE +22 -0
- usecortex_ai-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ..core.api_error import ApiError
|
|
7
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
10
|
+
from ..core.request_options import RequestOptions
|
|
11
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class RawUserMemoryClient:
|
|
15
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
16
|
+
self._client_wrapper = client_wrapper
|
|
17
|
+
|
|
18
|
+
def list_user_memories(
|
|
19
|
+
self, *, tenant_id: str, sub_tenant_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
20
|
+
) -> HttpResponse[typing.Optional[typing.Any]]:
|
|
21
|
+
"""
|
|
22
|
+
Parameters
|
|
23
|
+
----------
|
|
24
|
+
tenant_id : str
|
|
25
|
+
|
|
26
|
+
sub_tenant_id : str
|
|
27
|
+
|
|
28
|
+
request_options : typing.Optional[RequestOptions]
|
|
29
|
+
Request-specific configuration.
|
|
30
|
+
|
|
31
|
+
Returns
|
|
32
|
+
-------
|
|
33
|
+
HttpResponse[typing.Optional[typing.Any]]
|
|
34
|
+
Successful Response
|
|
35
|
+
"""
|
|
36
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
37
|
+
"user_memory/list_user_memories",
|
|
38
|
+
method="GET",
|
|
39
|
+
params={
|
|
40
|
+
"tenant_id": tenant_id,
|
|
41
|
+
"sub_tenant_id": sub_tenant_id,
|
|
42
|
+
},
|
|
43
|
+
request_options=request_options,
|
|
44
|
+
)
|
|
45
|
+
try:
|
|
46
|
+
if _response is None or not _response.text.strip():
|
|
47
|
+
return HttpResponse(response=_response, data=None)
|
|
48
|
+
if 200 <= _response.status_code < 300:
|
|
49
|
+
_data = typing.cast(
|
|
50
|
+
typing.Optional[typing.Any],
|
|
51
|
+
parse_obj_as(
|
|
52
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
53
|
+
object_=_response.json(),
|
|
54
|
+
),
|
|
55
|
+
)
|
|
56
|
+
return HttpResponse(response=_response, data=_data)
|
|
57
|
+
if _response.status_code == 422:
|
|
58
|
+
raise UnprocessableEntityError(
|
|
59
|
+
headers=dict(_response.headers),
|
|
60
|
+
body=typing.cast(
|
|
61
|
+
typing.Optional[typing.Any],
|
|
62
|
+
parse_obj_as(
|
|
63
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
64
|
+
object_=_response.json(),
|
|
65
|
+
),
|
|
66
|
+
),
|
|
67
|
+
)
|
|
68
|
+
_response_json = _response.json()
|
|
69
|
+
except JSONDecodeError:
|
|
70
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
71
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
72
|
+
|
|
73
|
+
def delete_user_memory(
|
|
74
|
+
self,
|
|
75
|
+
*,
|
|
76
|
+
tenant_id: str,
|
|
77
|
+
memory_id: str,
|
|
78
|
+
sub_tenant_id: str,
|
|
79
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
80
|
+
) -> HttpResponse[typing.Optional[typing.Any]]:
|
|
81
|
+
"""
|
|
82
|
+
Parameters
|
|
83
|
+
----------
|
|
84
|
+
tenant_id : str
|
|
85
|
+
|
|
86
|
+
memory_id : str
|
|
87
|
+
|
|
88
|
+
sub_tenant_id : str
|
|
89
|
+
|
|
90
|
+
request_options : typing.Optional[RequestOptions]
|
|
91
|
+
Request-specific configuration.
|
|
92
|
+
|
|
93
|
+
Returns
|
|
94
|
+
-------
|
|
95
|
+
HttpResponse[typing.Optional[typing.Any]]
|
|
96
|
+
Successful Response
|
|
97
|
+
"""
|
|
98
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
99
|
+
"user_memory/delete_user_memory",
|
|
100
|
+
method="DELETE",
|
|
101
|
+
params={
|
|
102
|
+
"tenant_id": tenant_id,
|
|
103
|
+
"memory_id": memory_id,
|
|
104
|
+
"sub_tenant_id": sub_tenant_id,
|
|
105
|
+
},
|
|
106
|
+
request_options=request_options,
|
|
107
|
+
)
|
|
108
|
+
try:
|
|
109
|
+
if _response is None or not _response.text.strip():
|
|
110
|
+
return HttpResponse(response=_response, data=None)
|
|
111
|
+
if 200 <= _response.status_code < 300:
|
|
112
|
+
_data = typing.cast(
|
|
113
|
+
typing.Optional[typing.Any],
|
|
114
|
+
parse_obj_as(
|
|
115
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
116
|
+
object_=_response.json(),
|
|
117
|
+
),
|
|
118
|
+
)
|
|
119
|
+
return HttpResponse(response=_response, data=_data)
|
|
120
|
+
if _response.status_code == 422:
|
|
121
|
+
raise UnprocessableEntityError(
|
|
122
|
+
headers=dict(_response.headers),
|
|
123
|
+
body=typing.cast(
|
|
124
|
+
typing.Optional[typing.Any],
|
|
125
|
+
parse_obj_as(
|
|
126
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
127
|
+
object_=_response.json(),
|
|
128
|
+
),
|
|
129
|
+
),
|
|
130
|
+
)
|
|
131
|
+
_response_json = _response.json()
|
|
132
|
+
except JSONDecodeError:
|
|
133
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
134
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
135
|
+
|
|
136
|
+
def retrieve_user_memory(
|
|
137
|
+
self,
|
|
138
|
+
*,
|
|
139
|
+
tenant_id: str,
|
|
140
|
+
query: str,
|
|
141
|
+
sub_tenant_id: str,
|
|
142
|
+
max_count: typing.Optional[int] = None,
|
|
143
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
144
|
+
) -> HttpResponse[typing.Optional[typing.Any]]:
|
|
145
|
+
"""
|
|
146
|
+
Parameters
|
|
147
|
+
----------
|
|
148
|
+
tenant_id : str
|
|
149
|
+
|
|
150
|
+
query : str
|
|
151
|
+
|
|
152
|
+
sub_tenant_id : str
|
|
153
|
+
|
|
154
|
+
max_count : typing.Optional[int]
|
|
155
|
+
|
|
156
|
+
request_options : typing.Optional[RequestOptions]
|
|
157
|
+
Request-specific configuration.
|
|
158
|
+
|
|
159
|
+
Returns
|
|
160
|
+
-------
|
|
161
|
+
HttpResponse[typing.Optional[typing.Any]]
|
|
162
|
+
Successful Response
|
|
163
|
+
"""
|
|
164
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
165
|
+
"user_memory/retrieve_user_memory",
|
|
166
|
+
method="GET",
|
|
167
|
+
params={
|
|
168
|
+
"tenant_id": tenant_id,
|
|
169
|
+
"query": query,
|
|
170
|
+
"sub_tenant_id": sub_tenant_id,
|
|
171
|
+
"max_count": max_count,
|
|
172
|
+
},
|
|
173
|
+
request_options=request_options,
|
|
174
|
+
)
|
|
175
|
+
try:
|
|
176
|
+
if _response is None or not _response.text.strip():
|
|
177
|
+
return HttpResponse(response=_response, data=None)
|
|
178
|
+
if 200 <= _response.status_code < 300:
|
|
179
|
+
_data = typing.cast(
|
|
180
|
+
typing.Optional[typing.Any],
|
|
181
|
+
parse_obj_as(
|
|
182
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
183
|
+
object_=_response.json(),
|
|
184
|
+
),
|
|
185
|
+
)
|
|
186
|
+
return HttpResponse(response=_response, data=_data)
|
|
187
|
+
if _response.status_code == 422:
|
|
188
|
+
raise UnprocessableEntityError(
|
|
189
|
+
headers=dict(_response.headers),
|
|
190
|
+
body=typing.cast(
|
|
191
|
+
typing.Optional[typing.Any],
|
|
192
|
+
parse_obj_as(
|
|
193
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
194
|
+
object_=_response.json(),
|
|
195
|
+
),
|
|
196
|
+
),
|
|
197
|
+
)
|
|
198
|
+
_response_json = _response.json()
|
|
199
|
+
except JSONDecodeError:
|
|
200
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
201
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
202
|
+
|
|
203
|
+
def generate_user_memory(
|
|
204
|
+
self,
|
|
205
|
+
*,
|
|
206
|
+
tenant_id: str,
|
|
207
|
+
user_query: str,
|
|
208
|
+
user_name: str,
|
|
209
|
+
sub_tenant_id: str,
|
|
210
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
211
|
+
) -> HttpResponse[typing.Optional[typing.Any]]:
|
|
212
|
+
"""
|
|
213
|
+
Parameters
|
|
214
|
+
----------
|
|
215
|
+
tenant_id : str
|
|
216
|
+
|
|
217
|
+
user_query : str
|
|
218
|
+
|
|
219
|
+
user_name : str
|
|
220
|
+
|
|
221
|
+
sub_tenant_id : str
|
|
222
|
+
|
|
223
|
+
request_options : typing.Optional[RequestOptions]
|
|
224
|
+
Request-specific configuration.
|
|
225
|
+
|
|
226
|
+
Returns
|
|
227
|
+
-------
|
|
228
|
+
HttpResponse[typing.Optional[typing.Any]]
|
|
229
|
+
Successful Response
|
|
230
|
+
"""
|
|
231
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
232
|
+
"user_memory/generate_user_memory",
|
|
233
|
+
method="POST",
|
|
234
|
+
params={
|
|
235
|
+
"tenant_id": tenant_id,
|
|
236
|
+
"user_query": user_query,
|
|
237
|
+
"user_name": user_name,
|
|
238
|
+
"sub_tenant_id": sub_tenant_id,
|
|
239
|
+
},
|
|
240
|
+
request_options=request_options,
|
|
241
|
+
)
|
|
242
|
+
try:
|
|
243
|
+
if _response is None or not _response.text.strip():
|
|
244
|
+
return HttpResponse(response=_response, data=None)
|
|
245
|
+
if 200 <= _response.status_code < 300:
|
|
246
|
+
_data = typing.cast(
|
|
247
|
+
typing.Optional[typing.Any],
|
|
248
|
+
parse_obj_as(
|
|
249
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
250
|
+
object_=_response.json(),
|
|
251
|
+
),
|
|
252
|
+
)
|
|
253
|
+
return HttpResponse(response=_response, data=_data)
|
|
254
|
+
if _response.status_code == 422:
|
|
255
|
+
raise UnprocessableEntityError(
|
|
256
|
+
headers=dict(_response.headers),
|
|
257
|
+
body=typing.cast(
|
|
258
|
+
typing.Optional[typing.Any],
|
|
259
|
+
parse_obj_as(
|
|
260
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
261
|
+
object_=_response.json(),
|
|
262
|
+
),
|
|
263
|
+
),
|
|
264
|
+
)
|
|
265
|
+
_response_json = _response.json()
|
|
266
|
+
except JSONDecodeError:
|
|
267
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
268
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
269
|
+
|
|
270
|
+
def add_user_memory(
|
|
271
|
+
self,
|
|
272
|
+
*,
|
|
273
|
+
tenant_id: str,
|
|
274
|
+
user_memory: str,
|
|
275
|
+
sub_tenant_id: str,
|
|
276
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
277
|
+
) -> HttpResponse[typing.Optional[typing.Any]]:
|
|
278
|
+
"""
|
|
279
|
+
Parameters
|
|
280
|
+
----------
|
|
281
|
+
tenant_id : str
|
|
282
|
+
|
|
283
|
+
user_memory : str
|
|
284
|
+
|
|
285
|
+
sub_tenant_id : str
|
|
286
|
+
|
|
287
|
+
request_options : typing.Optional[RequestOptions]
|
|
288
|
+
Request-specific configuration.
|
|
289
|
+
|
|
290
|
+
Returns
|
|
291
|
+
-------
|
|
292
|
+
HttpResponse[typing.Optional[typing.Any]]
|
|
293
|
+
Successful Response
|
|
294
|
+
"""
|
|
295
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
296
|
+
"user_memory/add_user_memory",
|
|
297
|
+
method="POST",
|
|
298
|
+
params={
|
|
299
|
+
"tenant_id": tenant_id,
|
|
300
|
+
"user_memory": user_memory,
|
|
301
|
+
"sub_tenant_id": sub_tenant_id,
|
|
302
|
+
},
|
|
303
|
+
request_options=request_options,
|
|
304
|
+
)
|
|
305
|
+
try:
|
|
306
|
+
if _response is None or not _response.text.strip():
|
|
307
|
+
return HttpResponse(response=_response, data=None)
|
|
308
|
+
if 200 <= _response.status_code < 300:
|
|
309
|
+
_data = typing.cast(
|
|
310
|
+
typing.Optional[typing.Any],
|
|
311
|
+
parse_obj_as(
|
|
312
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
313
|
+
object_=_response.json(),
|
|
314
|
+
),
|
|
315
|
+
)
|
|
316
|
+
return HttpResponse(response=_response, data=_data)
|
|
317
|
+
if _response.status_code == 422:
|
|
318
|
+
raise UnprocessableEntityError(
|
|
319
|
+
headers=dict(_response.headers),
|
|
320
|
+
body=typing.cast(
|
|
321
|
+
typing.Optional[typing.Any],
|
|
322
|
+
parse_obj_as(
|
|
323
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
324
|
+
object_=_response.json(),
|
|
325
|
+
),
|
|
326
|
+
),
|
|
327
|
+
)
|
|
328
|
+
_response_json = _response.json()
|
|
329
|
+
except JSONDecodeError:
|
|
330
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
331
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
class AsyncRawUserMemoryClient:
|
|
335
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
336
|
+
self._client_wrapper = client_wrapper
|
|
337
|
+
|
|
338
|
+
async def list_user_memories(
|
|
339
|
+
self, *, tenant_id: str, sub_tenant_id: str, request_options: typing.Optional[RequestOptions] = None
|
|
340
|
+
) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
|
|
341
|
+
"""
|
|
342
|
+
Parameters
|
|
343
|
+
----------
|
|
344
|
+
tenant_id : str
|
|
345
|
+
|
|
346
|
+
sub_tenant_id : str
|
|
347
|
+
|
|
348
|
+
request_options : typing.Optional[RequestOptions]
|
|
349
|
+
Request-specific configuration.
|
|
350
|
+
|
|
351
|
+
Returns
|
|
352
|
+
-------
|
|
353
|
+
AsyncHttpResponse[typing.Optional[typing.Any]]
|
|
354
|
+
Successful Response
|
|
355
|
+
"""
|
|
356
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
357
|
+
"user_memory/list_user_memories",
|
|
358
|
+
method="GET",
|
|
359
|
+
params={
|
|
360
|
+
"tenant_id": tenant_id,
|
|
361
|
+
"sub_tenant_id": sub_tenant_id,
|
|
362
|
+
},
|
|
363
|
+
request_options=request_options,
|
|
364
|
+
)
|
|
365
|
+
try:
|
|
366
|
+
if _response is None or not _response.text.strip():
|
|
367
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
368
|
+
if 200 <= _response.status_code < 300:
|
|
369
|
+
_data = typing.cast(
|
|
370
|
+
typing.Optional[typing.Any],
|
|
371
|
+
parse_obj_as(
|
|
372
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
373
|
+
object_=_response.json(),
|
|
374
|
+
),
|
|
375
|
+
)
|
|
376
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
377
|
+
if _response.status_code == 422:
|
|
378
|
+
raise UnprocessableEntityError(
|
|
379
|
+
headers=dict(_response.headers),
|
|
380
|
+
body=typing.cast(
|
|
381
|
+
typing.Optional[typing.Any],
|
|
382
|
+
parse_obj_as(
|
|
383
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
384
|
+
object_=_response.json(),
|
|
385
|
+
),
|
|
386
|
+
),
|
|
387
|
+
)
|
|
388
|
+
_response_json = _response.json()
|
|
389
|
+
except JSONDecodeError:
|
|
390
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
391
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
392
|
+
|
|
393
|
+
async def delete_user_memory(
|
|
394
|
+
self,
|
|
395
|
+
*,
|
|
396
|
+
tenant_id: str,
|
|
397
|
+
memory_id: str,
|
|
398
|
+
sub_tenant_id: str,
|
|
399
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
400
|
+
) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
|
|
401
|
+
"""
|
|
402
|
+
Parameters
|
|
403
|
+
----------
|
|
404
|
+
tenant_id : str
|
|
405
|
+
|
|
406
|
+
memory_id : str
|
|
407
|
+
|
|
408
|
+
sub_tenant_id : str
|
|
409
|
+
|
|
410
|
+
request_options : typing.Optional[RequestOptions]
|
|
411
|
+
Request-specific configuration.
|
|
412
|
+
|
|
413
|
+
Returns
|
|
414
|
+
-------
|
|
415
|
+
AsyncHttpResponse[typing.Optional[typing.Any]]
|
|
416
|
+
Successful Response
|
|
417
|
+
"""
|
|
418
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
419
|
+
"user_memory/delete_user_memory",
|
|
420
|
+
method="DELETE",
|
|
421
|
+
params={
|
|
422
|
+
"tenant_id": tenant_id,
|
|
423
|
+
"memory_id": memory_id,
|
|
424
|
+
"sub_tenant_id": sub_tenant_id,
|
|
425
|
+
},
|
|
426
|
+
request_options=request_options,
|
|
427
|
+
)
|
|
428
|
+
try:
|
|
429
|
+
if _response is None or not _response.text.strip():
|
|
430
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
431
|
+
if 200 <= _response.status_code < 300:
|
|
432
|
+
_data = typing.cast(
|
|
433
|
+
typing.Optional[typing.Any],
|
|
434
|
+
parse_obj_as(
|
|
435
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
436
|
+
object_=_response.json(),
|
|
437
|
+
),
|
|
438
|
+
)
|
|
439
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
440
|
+
if _response.status_code == 422:
|
|
441
|
+
raise UnprocessableEntityError(
|
|
442
|
+
headers=dict(_response.headers),
|
|
443
|
+
body=typing.cast(
|
|
444
|
+
typing.Optional[typing.Any],
|
|
445
|
+
parse_obj_as(
|
|
446
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
447
|
+
object_=_response.json(),
|
|
448
|
+
),
|
|
449
|
+
),
|
|
450
|
+
)
|
|
451
|
+
_response_json = _response.json()
|
|
452
|
+
except JSONDecodeError:
|
|
453
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
454
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
455
|
+
|
|
456
|
+
async def retrieve_user_memory(
|
|
457
|
+
self,
|
|
458
|
+
*,
|
|
459
|
+
tenant_id: str,
|
|
460
|
+
query: str,
|
|
461
|
+
sub_tenant_id: str,
|
|
462
|
+
max_count: typing.Optional[int] = None,
|
|
463
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
464
|
+
) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
|
|
465
|
+
"""
|
|
466
|
+
Parameters
|
|
467
|
+
----------
|
|
468
|
+
tenant_id : str
|
|
469
|
+
|
|
470
|
+
query : str
|
|
471
|
+
|
|
472
|
+
sub_tenant_id : str
|
|
473
|
+
|
|
474
|
+
max_count : typing.Optional[int]
|
|
475
|
+
|
|
476
|
+
request_options : typing.Optional[RequestOptions]
|
|
477
|
+
Request-specific configuration.
|
|
478
|
+
|
|
479
|
+
Returns
|
|
480
|
+
-------
|
|
481
|
+
AsyncHttpResponse[typing.Optional[typing.Any]]
|
|
482
|
+
Successful Response
|
|
483
|
+
"""
|
|
484
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
485
|
+
"user_memory/retrieve_user_memory",
|
|
486
|
+
method="GET",
|
|
487
|
+
params={
|
|
488
|
+
"tenant_id": tenant_id,
|
|
489
|
+
"query": query,
|
|
490
|
+
"sub_tenant_id": sub_tenant_id,
|
|
491
|
+
"max_count": max_count,
|
|
492
|
+
},
|
|
493
|
+
request_options=request_options,
|
|
494
|
+
)
|
|
495
|
+
try:
|
|
496
|
+
if _response is None or not _response.text.strip():
|
|
497
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
498
|
+
if 200 <= _response.status_code < 300:
|
|
499
|
+
_data = typing.cast(
|
|
500
|
+
typing.Optional[typing.Any],
|
|
501
|
+
parse_obj_as(
|
|
502
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
503
|
+
object_=_response.json(),
|
|
504
|
+
),
|
|
505
|
+
)
|
|
506
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
507
|
+
if _response.status_code == 422:
|
|
508
|
+
raise UnprocessableEntityError(
|
|
509
|
+
headers=dict(_response.headers),
|
|
510
|
+
body=typing.cast(
|
|
511
|
+
typing.Optional[typing.Any],
|
|
512
|
+
parse_obj_as(
|
|
513
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
514
|
+
object_=_response.json(),
|
|
515
|
+
),
|
|
516
|
+
),
|
|
517
|
+
)
|
|
518
|
+
_response_json = _response.json()
|
|
519
|
+
except JSONDecodeError:
|
|
520
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
521
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
522
|
+
|
|
523
|
+
async def generate_user_memory(
|
|
524
|
+
self,
|
|
525
|
+
*,
|
|
526
|
+
tenant_id: str,
|
|
527
|
+
user_query: str,
|
|
528
|
+
user_name: str,
|
|
529
|
+
sub_tenant_id: str,
|
|
530
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
531
|
+
) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
|
|
532
|
+
"""
|
|
533
|
+
Parameters
|
|
534
|
+
----------
|
|
535
|
+
tenant_id : str
|
|
536
|
+
|
|
537
|
+
user_query : str
|
|
538
|
+
|
|
539
|
+
user_name : str
|
|
540
|
+
|
|
541
|
+
sub_tenant_id : str
|
|
542
|
+
|
|
543
|
+
request_options : typing.Optional[RequestOptions]
|
|
544
|
+
Request-specific configuration.
|
|
545
|
+
|
|
546
|
+
Returns
|
|
547
|
+
-------
|
|
548
|
+
AsyncHttpResponse[typing.Optional[typing.Any]]
|
|
549
|
+
Successful Response
|
|
550
|
+
"""
|
|
551
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
552
|
+
"user_memory/generate_user_memory",
|
|
553
|
+
method="POST",
|
|
554
|
+
params={
|
|
555
|
+
"tenant_id": tenant_id,
|
|
556
|
+
"user_query": user_query,
|
|
557
|
+
"user_name": user_name,
|
|
558
|
+
"sub_tenant_id": sub_tenant_id,
|
|
559
|
+
},
|
|
560
|
+
request_options=request_options,
|
|
561
|
+
)
|
|
562
|
+
try:
|
|
563
|
+
if _response is None or not _response.text.strip():
|
|
564
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
565
|
+
if 200 <= _response.status_code < 300:
|
|
566
|
+
_data = typing.cast(
|
|
567
|
+
typing.Optional[typing.Any],
|
|
568
|
+
parse_obj_as(
|
|
569
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
570
|
+
object_=_response.json(),
|
|
571
|
+
),
|
|
572
|
+
)
|
|
573
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
574
|
+
if _response.status_code == 422:
|
|
575
|
+
raise UnprocessableEntityError(
|
|
576
|
+
headers=dict(_response.headers),
|
|
577
|
+
body=typing.cast(
|
|
578
|
+
typing.Optional[typing.Any],
|
|
579
|
+
parse_obj_as(
|
|
580
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
581
|
+
object_=_response.json(),
|
|
582
|
+
),
|
|
583
|
+
),
|
|
584
|
+
)
|
|
585
|
+
_response_json = _response.json()
|
|
586
|
+
except JSONDecodeError:
|
|
587
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
588
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
589
|
+
|
|
590
|
+
async def add_user_memory(
|
|
591
|
+
self,
|
|
592
|
+
*,
|
|
593
|
+
tenant_id: str,
|
|
594
|
+
user_memory: str,
|
|
595
|
+
sub_tenant_id: str,
|
|
596
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
597
|
+
) -> AsyncHttpResponse[typing.Optional[typing.Any]]:
|
|
598
|
+
"""
|
|
599
|
+
Parameters
|
|
600
|
+
----------
|
|
601
|
+
tenant_id : str
|
|
602
|
+
|
|
603
|
+
user_memory : str
|
|
604
|
+
|
|
605
|
+
sub_tenant_id : str
|
|
606
|
+
|
|
607
|
+
request_options : typing.Optional[RequestOptions]
|
|
608
|
+
Request-specific configuration.
|
|
609
|
+
|
|
610
|
+
Returns
|
|
611
|
+
-------
|
|
612
|
+
AsyncHttpResponse[typing.Optional[typing.Any]]
|
|
613
|
+
Successful Response
|
|
614
|
+
"""
|
|
615
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
616
|
+
"user_memory/add_user_memory",
|
|
617
|
+
method="POST",
|
|
618
|
+
params={
|
|
619
|
+
"tenant_id": tenant_id,
|
|
620
|
+
"user_memory": user_memory,
|
|
621
|
+
"sub_tenant_id": sub_tenant_id,
|
|
622
|
+
},
|
|
623
|
+
request_options=request_options,
|
|
624
|
+
)
|
|
625
|
+
try:
|
|
626
|
+
if _response is None or not _response.text.strip():
|
|
627
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
628
|
+
if 200 <= _response.status_code < 300:
|
|
629
|
+
_data = typing.cast(
|
|
630
|
+
typing.Optional[typing.Any],
|
|
631
|
+
parse_obj_as(
|
|
632
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
633
|
+
object_=_response.json(),
|
|
634
|
+
),
|
|
635
|
+
)
|
|
636
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
637
|
+
if _response.status_code == 422:
|
|
638
|
+
raise UnprocessableEntityError(
|
|
639
|
+
headers=dict(_response.headers),
|
|
640
|
+
body=typing.cast(
|
|
641
|
+
typing.Optional[typing.Any],
|
|
642
|
+
parse_obj_as(
|
|
643
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
644
|
+
object_=_response.json(),
|
|
645
|
+
),
|
|
646
|
+
),
|
|
647
|
+
)
|
|
648
|
+
_response_json = _response.json()
|
|
649
|
+
except JSONDecodeError:
|
|
650
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
651
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|