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.
Files changed (89) hide show
  1. cortex_ai/__init__.py +103 -0
  2. cortex_ai/client.py +244 -0
  3. cortex_ai/core/__init__.py +52 -0
  4. cortex_ai/core/api_error.py +23 -0
  5. cortex_ai/core/client_wrapper.py +84 -0
  6. cortex_ai/core/datetime_utils.py +28 -0
  7. cortex_ai/core/file.py +67 -0
  8. cortex_ai/core/force_multipart.py +18 -0
  9. cortex_ai/core/http_client.py +543 -0
  10. cortex_ai/core/http_response.py +55 -0
  11. cortex_ai/core/jsonable_encoder.py +100 -0
  12. cortex_ai/core/pydantic_utilities.py +258 -0
  13. cortex_ai/core/query_encoder.py +58 -0
  14. cortex_ai/core/remove_none_from_dict.py +11 -0
  15. cortex_ai/core/request_options.py +35 -0
  16. cortex_ai/core/serialization.py +276 -0
  17. cortex_ai/embeddings/__init__.py +4 -0
  18. cortex_ai/embeddings/client.py +442 -0
  19. cortex_ai/embeddings/raw_client.py +1153 -0
  20. cortex_ai/environment.py +7 -0
  21. cortex_ai/errors/__init__.py +21 -0
  22. cortex_ai/errors/bad_request_error.py +11 -0
  23. cortex_ai/errors/forbidden_error.py +11 -0
  24. cortex_ai/errors/internal_server_error.py +11 -0
  25. cortex_ai/errors/not_found_error.py +11 -0
  26. cortex_ai/errors/service_unavailable_error.py +11 -0
  27. cortex_ai/errors/unauthorized_error.py +11 -0
  28. cortex_ai/errors/unprocessable_entity_error.py +10 -0
  29. cortex_ai/fetch/__init__.py +4 -0
  30. cortex_ai/fetch/client.py +143 -0
  31. cortex_ai/fetch/raw_client.py +310 -0
  32. cortex_ai/raw_client.py +90 -0
  33. cortex_ai/search/__init__.py +7 -0
  34. cortex_ai/search/client.py +536 -0
  35. cortex_ai/search/raw_client.py +1064 -0
  36. cortex_ai/search/types/__init__.py +7 -0
  37. cortex_ai/search/types/alpha.py +5 -0
  38. cortex_ai/sources/__init__.py +4 -0
  39. cortex_ai/sources/client.py +187 -0
  40. cortex_ai/sources/raw_client.py +532 -0
  41. cortex_ai/tenant/__init__.py +4 -0
  42. cortex_ai/tenant/client.py +120 -0
  43. cortex_ai/tenant/raw_client.py +283 -0
  44. cortex_ai/types/__init__.py +69 -0
  45. cortex_ai/types/actual_error_response.py +20 -0
  46. cortex_ai/types/app_sources_upload_data.py +22 -0
  47. cortex_ai/types/attachment_model.py +26 -0
  48. cortex_ai/types/batch_upload_data.py +22 -0
  49. cortex_ai/types/bm_25_operator_type.py +5 -0
  50. cortex_ai/types/content_model.py +26 -0
  51. cortex_ai/types/delete_memory_request.py +21 -0
  52. cortex_ai/types/embeddings_create_collection_data.py +22 -0
  53. cortex_ai/types/embeddings_delete_data.py +22 -0
  54. cortex_ai/types/embeddings_get_data.py +22 -0
  55. cortex_ai/types/embeddings_search_data.py +22 -0
  56. cortex_ai/types/error_response.py +22 -0
  57. cortex_ai/types/extended_context.py +20 -0
  58. cortex_ai/types/fetch_content_data.py +23 -0
  59. cortex_ai/types/file_upload_result.py +20 -0
  60. cortex_ai/types/full_text_search_data.py +22 -0
  61. cortex_ai/types/http_validation_error.py +20 -0
  62. cortex_ai/types/list_sources_response.py +22 -0
  63. cortex_ai/types/markdown_upload_request.py +21 -0
  64. cortex_ai/types/processing_status.py +22 -0
  65. cortex_ai/types/related_chunk.py +22 -0
  66. cortex_ai/types/search_chunk.py +34 -0
  67. cortex_ai/types/search_data.py +22 -0
  68. cortex_ai/types/single_upload_data.py +21 -0
  69. cortex_ai/types/source.py +32 -0
  70. cortex_ai/types/source_content.py +26 -0
  71. cortex_ai/types/source_model.py +32 -0
  72. cortex_ai/types/tenant_create_data.py +22 -0
  73. cortex_ai/types/tenant_stats.py +23 -0
  74. cortex_ai/types/validation_error.py +22 -0
  75. cortex_ai/types/validation_error_loc_item.py +5 -0
  76. cortex_ai/upload/__init__.py +4 -0
  77. cortex_ai/upload/client.py +1572 -0
  78. cortex_ai/upload/raw_client.py +4202 -0
  79. cortex_ai/user/__init__.py +4 -0
  80. cortex_ai/user/client.py +125 -0
  81. cortex_ai/user/raw_client.py +300 -0
  82. cortex_ai/user_memory/__init__.py +4 -0
  83. cortex_ai/user_memory/client.py +443 -0
  84. cortex_ai/user_memory/raw_client.py +651 -0
  85. usecortex_ai-0.1.0.dist-info/METADATA +136 -0
  86. usecortex_ai-0.1.0.dist-info/RECORD +89 -0
  87. usecortex_ai-0.1.0.dist-info/WHEEL +5 -0
  88. usecortex_ai-0.1.0.dist-info/licenses/LICENSE +22 -0
  89. usecortex_ai-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,4 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
@@ -0,0 +1,125 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
+ from ..core.request_options import RequestOptions
7
+ from ..types.tenant_create_data import TenantCreateData
8
+ from .raw_client import AsyncRawUserClient, RawUserClient
9
+
10
+ # this is used as the default value for optional parameters
11
+ OMIT = typing.cast(typing.Any, ...)
12
+
13
+
14
+ class UserClient:
15
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
16
+ self._raw_client = RawUserClient(client_wrapper=client_wrapper)
17
+
18
+ @property
19
+ def with_raw_response(self) -> RawUserClient:
20
+ """
21
+ Retrieves a raw implementation of this client that returns raw responses.
22
+
23
+ Returns
24
+ -------
25
+ RawUserClient
26
+ """
27
+ return self._raw_client
28
+
29
+ def create_tenant(
30
+ self,
31
+ *,
32
+ tenant_id: typing.Optional[str] = None,
33
+ tenant_metadata_schema: typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]] = OMIT,
34
+ request_options: typing.Optional[RequestOptions] = None,
35
+ ) -> TenantCreateData:
36
+ """
37
+ Create a new tenant for the authenticated user.
38
+
39
+ Returns:
40
+ TenantCreateResponse: Success response with tenant creation details
41
+
42
+ Parameters
43
+ ----------
44
+ tenant_id : typing.Optional[str]
45
+
46
+ tenant_metadata_schema : typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]]
47
+
48
+ request_options : typing.Optional[RequestOptions]
49
+ Request-specific configuration.
50
+
51
+ Returns
52
+ -------
53
+ TenantCreateData
54
+ Successful Response
55
+
56
+ Examples
57
+ --------
58
+ from cortex-ai import CortexAI
59
+
60
+ client = CortexAI(token="YOUR_TOKEN", )
61
+ client.user.create_tenant()
62
+ """
63
+ _response = self._raw_client.create_tenant(
64
+ tenant_id=tenant_id, tenant_metadata_schema=tenant_metadata_schema, request_options=request_options
65
+ )
66
+ return _response.data
67
+
68
+
69
+ class AsyncUserClient:
70
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
71
+ self._raw_client = AsyncRawUserClient(client_wrapper=client_wrapper)
72
+
73
+ @property
74
+ def with_raw_response(self) -> AsyncRawUserClient:
75
+ """
76
+ Retrieves a raw implementation of this client that returns raw responses.
77
+
78
+ Returns
79
+ -------
80
+ AsyncRawUserClient
81
+ """
82
+ return self._raw_client
83
+
84
+ async def create_tenant(
85
+ self,
86
+ *,
87
+ tenant_id: typing.Optional[str] = None,
88
+ tenant_metadata_schema: typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]] = OMIT,
89
+ request_options: typing.Optional[RequestOptions] = None,
90
+ ) -> TenantCreateData:
91
+ """
92
+ Create a new tenant for the authenticated user.
93
+
94
+ Returns:
95
+ TenantCreateResponse: Success response with tenant creation details
96
+
97
+ Parameters
98
+ ----------
99
+ tenant_id : typing.Optional[str]
100
+
101
+ tenant_metadata_schema : typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]]
102
+
103
+ request_options : typing.Optional[RequestOptions]
104
+ Request-specific configuration.
105
+
106
+ Returns
107
+ -------
108
+ TenantCreateData
109
+ Successful Response
110
+
111
+ Examples
112
+ --------
113
+ import asyncio
114
+
115
+ from cortex-ai import AsyncCortexAI
116
+
117
+ client = AsyncCortexAI(token="YOUR_TOKEN", )
118
+ async def main() -> None:
119
+ await client.user.create_tenant()
120
+ asyncio.run(main())
121
+ """
122
+ _response = await self._raw_client.create_tenant(
123
+ tenant_id=tenant_id, tenant_metadata_schema=tenant_metadata_schema, request_options=request_options
124
+ )
125
+ return _response.data
@@ -0,0 +1,300 @@
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.bad_request_error import BadRequestError
12
+ from ..errors.forbidden_error import ForbiddenError
13
+ from ..errors.internal_server_error import InternalServerError
14
+ from ..errors.not_found_error import NotFoundError
15
+ from ..errors.service_unavailable_error import ServiceUnavailableError
16
+ from ..errors.unauthorized_error import UnauthorizedError
17
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
18
+ from ..types.actual_error_response import ActualErrorResponse
19
+ from ..types.tenant_create_data import TenantCreateData
20
+
21
+ # this is used as the default value for optional parameters
22
+ OMIT = typing.cast(typing.Any, ...)
23
+
24
+
25
+ class RawUserClient:
26
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
27
+ self._client_wrapper = client_wrapper
28
+
29
+ def create_tenant(
30
+ self,
31
+ *,
32
+ tenant_id: typing.Optional[str] = None,
33
+ tenant_metadata_schema: typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]] = OMIT,
34
+ request_options: typing.Optional[RequestOptions] = None,
35
+ ) -> HttpResponse[TenantCreateData]:
36
+ """
37
+ Create a new tenant for the authenticated user.
38
+
39
+ Returns:
40
+ TenantCreateResponse: Success response with tenant creation details
41
+
42
+ Parameters
43
+ ----------
44
+ tenant_id : typing.Optional[str]
45
+
46
+ tenant_metadata_schema : typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]]
47
+
48
+ request_options : typing.Optional[RequestOptions]
49
+ Request-specific configuration.
50
+
51
+ Returns
52
+ -------
53
+ HttpResponse[TenantCreateData]
54
+ Successful Response
55
+ """
56
+ _response = self._client_wrapper.httpx_client.request(
57
+ "user/create_tenant",
58
+ method="POST",
59
+ params={
60
+ "tenant_id": tenant_id,
61
+ },
62
+ json={
63
+ "tenant_metadata_schema": tenant_metadata_schema,
64
+ },
65
+ headers={
66
+ "content-type": "application/json",
67
+ },
68
+ request_options=request_options,
69
+ omit=OMIT,
70
+ )
71
+ try:
72
+ if 200 <= _response.status_code < 300:
73
+ _data = typing.cast(
74
+ TenantCreateData,
75
+ parse_obj_as(
76
+ type_=TenantCreateData, # type: ignore
77
+ object_=_response.json(),
78
+ ),
79
+ )
80
+ return HttpResponse(response=_response, data=_data)
81
+ if _response.status_code == 400:
82
+ raise BadRequestError(
83
+ headers=dict(_response.headers),
84
+ body=typing.cast(
85
+ ActualErrorResponse,
86
+ parse_obj_as(
87
+ type_=ActualErrorResponse, # type: ignore
88
+ object_=_response.json(),
89
+ ),
90
+ ),
91
+ )
92
+ if _response.status_code == 401:
93
+ raise UnauthorizedError(
94
+ headers=dict(_response.headers),
95
+ body=typing.cast(
96
+ ActualErrorResponse,
97
+ parse_obj_as(
98
+ type_=ActualErrorResponse, # type: ignore
99
+ object_=_response.json(),
100
+ ),
101
+ ),
102
+ )
103
+ if _response.status_code == 403:
104
+ raise ForbiddenError(
105
+ headers=dict(_response.headers),
106
+ body=typing.cast(
107
+ ActualErrorResponse,
108
+ parse_obj_as(
109
+ type_=ActualErrorResponse, # type: ignore
110
+ object_=_response.json(),
111
+ ),
112
+ ),
113
+ )
114
+ if _response.status_code == 404:
115
+ raise NotFoundError(
116
+ headers=dict(_response.headers),
117
+ body=typing.cast(
118
+ ActualErrorResponse,
119
+ parse_obj_as(
120
+ type_=ActualErrorResponse, # type: ignore
121
+ object_=_response.json(),
122
+ ),
123
+ ),
124
+ )
125
+ if _response.status_code == 422:
126
+ raise UnprocessableEntityError(
127
+ headers=dict(_response.headers),
128
+ body=typing.cast(
129
+ typing.Optional[typing.Any],
130
+ parse_obj_as(
131
+ type_=typing.Optional[typing.Any], # type: ignore
132
+ object_=_response.json(),
133
+ ),
134
+ ),
135
+ )
136
+ if _response.status_code == 500:
137
+ raise InternalServerError(
138
+ headers=dict(_response.headers),
139
+ body=typing.cast(
140
+ ActualErrorResponse,
141
+ parse_obj_as(
142
+ type_=ActualErrorResponse, # type: ignore
143
+ object_=_response.json(),
144
+ ),
145
+ ),
146
+ )
147
+ if _response.status_code == 503:
148
+ raise ServiceUnavailableError(
149
+ headers=dict(_response.headers),
150
+ body=typing.cast(
151
+ ActualErrorResponse,
152
+ parse_obj_as(
153
+ type_=ActualErrorResponse, # type: ignore
154
+ object_=_response.json(),
155
+ ),
156
+ ),
157
+ )
158
+ _response_json = _response.json()
159
+ except JSONDecodeError:
160
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
161
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
162
+
163
+
164
+ class AsyncRawUserClient:
165
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
166
+ self._client_wrapper = client_wrapper
167
+
168
+ async def create_tenant(
169
+ self,
170
+ *,
171
+ tenant_id: typing.Optional[str] = None,
172
+ tenant_metadata_schema: typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]] = OMIT,
173
+ request_options: typing.Optional[RequestOptions] = None,
174
+ ) -> AsyncHttpResponse[TenantCreateData]:
175
+ """
176
+ Create a new tenant for the authenticated user.
177
+
178
+ Returns:
179
+ TenantCreateResponse: Success response with tenant creation details
180
+
181
+ Parameters
182
+ ----------
183
+ tenant_id : typing.Optional[str]
184
+
185
+ tenant_metadata_schema : typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]]
186
+
187
+ request_options : typing.Optional[RequestOptions]
188
+ Request-specific configuration.
189
+
190
+ Returns
191
+ -------
192
+ AsyncHttpResponse[TenantCreateData]
193
+ Successful Response
194
+ """
195
+ _response = await self._client_wrapper.httpx_client.request(
196
+ "user/create_tenant",
197
+ method="POST",
198
+ params={
199
+ "tenant_id": tenant_id,
200
+ },
201
+ json={
202
+ "tenant_metadata_schema": tenant_metadata_schema,
203
+ },
204
+ headers={
205
+ "content-type": "application/json",
206
+ },
207
+ request_options=request_options,
208
+ omit=OMIT,
209
+ )
210
+ try:
211
+ if 200 <= _response.status_code < 300:
212
+ _data = typing.cast(
213
+ TenantCreateData,
214
+ parse_obj_as(
215
+ type_=TenantCreateData, # type: ignore
216
+ object_=_response.json(),
217
+ ),
218
+ )
219
+ return AsyncHttpResponse(response=_response, data=_data)
220
+ if _response.status_code == 400:
221
+ raise BadRequestError(
222
+ headers=dict(_response.headers),
223
+ body=typing.cast(
224
+ ActualErrorResponse,
225
+ parse_obj_as(
226
+ type_=ActualErrorResponse, # type: ignore
227
+ object_=_response.json(),
228
+ ),
229
+ ),
230
+ )
231
+ if _response.status_code == 401:
232
+ raise UnauthorizedError(
233
+ headers=dict(_response.headers),
234
+ body=typing.cast(
235
+ ActualErrorResponse,
236
+ parse_obj_as(
237
+ type_=ActualErrorResponse, # type: ignore
238
+ object_=_response.json(),
239
+ ),
240
+ ),
241
+ )
242
+ if _response.status_code == 403:
243
+ raise ForbiddenError(
244
+ headers=dict(_response.headers),
245
+ body=typing.cast(
246
+ ActualErrorResponse,
247
+ parse_obj_as(
248
+ type_=ActualErrorResponse, # type: ignore
249
+ object_=_response.json(),
250
+ ),
251
+ ),
252
+ )
253
+ if _response.status_code == 404:
254
+ raise NotFoundError(
255
+ headers=dict(_response.headers),
256
+ body=typing.cast(
257
+ ActualErrorResponse,
258
+ parse_obj_as(
259
+ type_=ActualErrorResponse, # type: ignore
260
+ object_=_response.json(),
261
+ ),
262
+ ),
263
+ )
264
+ if _response.status_code == 422:
265
+ raise UnprocessableEntityError(
266
+ headers=dict(_response.headers),
267
+ body=typing.cast(
268
+ typing.Optional[typing.Any],
269
+ parse_obj_as(
270
+ type_=typing.Optional[typing.Any], # type: ignore
271
+ object_=_response.json(),
272
+ ),
273
+ ),
274
+ )
275
+ if _response.status_code == 500:
276
+ raise InternalServerError(
277
+ headers=dict(_response.headers),
278
+ body=typing.cast(
279
+ ActualErrorResponse,
280
+ parse_obj_as(
281
+ type_=ActualErrorResponse, # type: ignore
282
+ object_=_response.json(),
283
+ ),
284
+ ),
285
+ )
286
+ if _response.status_code == 503:
287
+ raise ServiceUnavailableError(
288
+ headers=dict(_response.headers),
289
+ body=typing.cast(
290
+ ActualErrorResponse,
291
+ parse_obj_as(
292
+ type_=ActualErrorResponse, # type: ignore
293
+ object_=_response.json(),
294
+ ),
295
+ ),
296
+ )
297
+ _response_json = _response.json()
298
+ except JSONDecodeError:
299
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
300
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
@@ -0,0 +1,4 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+