usecortex-ai 0.2.1__py3-none-any.whl → 0.3.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 (61) hide show
  1. usecortex_ai/__init__.py +18 -3
  2. usecortex_ai/client.py +3 -0
  3. usecortex_ai/document/__init__.py +4 -0
  4. usecortex_ai/document/client.py +139 -0
  5. usecortex_ai/document/raw_client.py +312 -0
  6. usecortex_ai/embeddings/client.py +48 -78
  7. usecortex_ai/embeddings/raw_client.py +44 -74
  8. usecortex_ai/fetch/client.py +2 -2
  9. usecortex_ai/search/client.py +88 -84
  10. usecortex_ai/search/raw_client.py +82 -78
  11. usecortex_ai/sources/client.py +26 -157
  12. usecortex_ai/sources/raw_client.py +22 -501
  13. usecortex_ai/tenant/client.py +154 -6
  14. usecortex_ai/tenant/raw_client.py +502 -4
  15. usecortex_ai/types/__init__.py +16 -2
  16. usecortex_ai/types/add_user_memory_response.py +36 -0
  17. usecortex_ai/types/app_sources_upload_data.py +10 -2
  18. usecortex_ai/types/attachment_model.py +34 -7
  19. usecortex_ai/types/batch_upload_data.py +10 -2
  20. usecortex_ai/types/body_scrape_webpage_upload_scrape_webpage_post.py +0 -2
  21. usecortex_ai/types/body_update_scrape_job_upload_update_webpage_patch.py +0 -2
  22. usecortex_ai/types/content_model.py +33 -6
  23. usecortex_ai/types/delete_memory_request.py +14 -3
  24. usecortex_ai/types/delete_sources.py +20 -0
  25. usecortex_ai/types/delete_sub_tenant_data.py +42 -0
  26. usecortex_ai/types/delete_user_memory_response.py +31 -0
  27. usecortex_ai/types/embeddings_create_collection_data.py +19 -4
  28. usecortex_ai/types/embeddings_delete_data.py +19 -4
  29. usecortex_ai/types/embeddings_get_data.py +19 -4
  30. usecortex_ai/types/embeddings_search_data.py +19 -4
  31. usecortex_ai/types/error_response.py +0 -1
  32. usecortex_ai/types/fetch_content_data.py +19 -5
  33. usecortex_ai/types/file_upload_result.py +9 -2
  34. usecortex_ai/types/generate_user_memory_response.py +32 -0
  35. usecortex_ai/types/list_sources_response.py +14 -3
  36. usecortex_ai/types/list_user_memories_response.py +32 -0
  37. usecortex_ai/types/markdown_upload_request.py +23 -5
  38. usecortex_ai/types/processing_status.py +14 -3
  39. usecortex_ai/types/relations.py +9 -2
  40. usecortex_ai/types/retrieve_user_memory_response.py +32 -0
  41. usecortex_ai/types/search_chunk.py +54 -17
  42. usecortex_ai/types/single_upload_data.py +10 -2
  43. usecortex_ai/types/source.py +34 -15
  44. usecortex_ai/types/source_model.py +63 -14
  45. usecortex_ai/types/sub_tenant_ids_data.py +29 -5
  46. usecortex_ai/types/tenant_create_data.py +19 -4
  47. usecortex_ai/types/tenant_stats.py +24 -5
  48. usecortex_ai/types/user_memory.py +31 -0
  49. usecortex_ai/upload/client.py +486 -111
  50. usecortex_ai/upload/raw_client.py +458 -103
  51. usecortex_ai/user/client.py +30 -10
  52. usecortex_ai/user/raw_client.py +22 -6
  53. usecortex_ai/user_memory/client.py +200 -56
  54. usecortex_ai/user_memory/raw_client.py +921 -94
  55. {usecortex_ai-0.2.1.dist-info → usecortex_ai-0.3.0.dist-info}/METADATA +1 -1
  56. usecortex_ai-0.3.0.dist-info/RECORD +101 -0
  57. usecortex_ai/types/source_content.py +0 -26
  58. usecortex_ai-0.2.1.dist-info/RECORD +0 -91
  59. {usecortex_ai-0.2.1.dist-info → usecortex_ai-0.3.0.dist-info}/WHEEL +0 -0
  60. {usecortex_ai-0.2.1.dist-info → usecortex_ai-0.3.0.dist-info}/licenses/LICENSE +0 -0
  61. {usecortex_ai-0.2.1.dist-info → usecortex_ai-0.3.0.dist-info}/top_level.txt +0 -0
usecortex_ai/__init__.py CHANGED
@@ -4,6 +4,7 @@
4
4
 
5
5
  from .types import (
6
6
  ActualErrorResponse,
7
+ AddUserMemoryResponse,
7
8
  AppSourcesUploadData,
8
9
  AttachmentModel,
9
10
  BatchUploadData,
@@ -12,6 +13,9 @@ from .types import (
12
13
  BodyUpdateScrapeJobUploadUpdateWebpagePatch,
13
14
  ContentModel,
14
15
  DeleteMemoryRequest,
16
+ DeleteSources,
17
+ DeleteSubTenantData,
18
+ DeleteUserMemoryResponse,
15
19
  EmbeddingsCreateCollectionData,
16
20
  EmbeddingsDeleteData,
17
21
  EmbeddingsGetData,
@@ -20,20 +24,23 @@ from .types import (
20
24
  ExtendedContext,
21
25
  FetchContentData,
22
26
  FileUploadResult,
27
+ GenerateUserMemoryResponse,
23
28
  HttpValidationError,
24
29
  ListSourcesResponse,
30
+ ListUserMemoriesResponse,
25
31
  MarkdownUploadRequest,
26
32
  ProcessingStatus,
27
33
  RelatedChunk,
28
34
  Relations,
35
+ RetrieveUserMemoryResponse,
29
36
  SearchChunk,
30
37
  SingleUploadData,
31
38
  Source,
32
- SourceContent,
33
39
  SourceModel,
34
40
  SubTenantIdsData,
35
41
  TenantCreateData,
36
42
  TenantStats,
43
+ UserMemory,
37
44
  ValidationError,
38
45
  ValidationErrorLocItem,
39
46
  )
@@ -46,13 +53,14 @@ from .errors import (
46
53
  UnauthorizedError,
47
54
  UnprocessableEntityError,
48
55
  )
49
- from . import embeddings, fetch, search, sources, tenant, upload, user, user_memory
56
+ from . import document, embeddings, fetch, search, sources, tenant, upload, user, user_memory
50
57
  from .client import AsyncCortexAI, CortexAI
51
58
  from .environment import CortexAIEnvironment
52
59
  from .search import Alpha
53
60
 
54
61
  __all__ = [
55
62
  "ActualErrorResponse",
63
+ "AddUserMemoryResponse",
56
64
  "Alpha",
57
65
  "AppSourcesUploadData",
58
66
  "AsyncCortexAI",
@@ -66,6 +74,9 @@ __all__ = [
66
74
  "CortexAI",
67
75
  "CortexAIEnvironment",
68
76
  "DeleteMemoryRequest",
77
+ "DeleteSources",
78
+ "DeleteSubTenantData",
79
+ "DeleteUserMemoryResponse",
69
80
  "EmbeddingsCreateCollectionData",
70
81
  "EmbeddingsDeleteData",
71
82
  "EmbeddingsGetData",
@@ -75,27 +86,31 @@ __all__ = [
75
86
  "FetchContentData",
76
87
  "FileUploadResult",
77
88
  "ForbiddenError",
89
+ "GenerateUserMemoryResponse",
78
90
  "HttpValidationError",
79
91
  "InternalServerError",
80
92
  "ListSourcesResponse",
93
+ "ListUserMemoriesResponse",
81
94
  "MarkdownUploadRequest",
82
95
  "NotFoundError",
83
96
  "ProcessingStatus",
84
97
  "RelatedChunk",
85
98
  "Relations",
99
+ "RetrieveUserMemoryResponse",
86
100
  "SearchChunk",
87
101
  "ServiceUnavailableError",
88
102
  "SingleUploadData",
89
103
  "Source",
90
- "SourceContent",
91
104
  "SourceModel",
92
105
  "SubTenantIdsData",
93
106
  "TenantCreateData",
94
107
  "TenantStats",
95
108
  "UnauthorizedError",
96
109
  "UnprocessableEntityError",
110
+ "UserMemory",
97
111
  "ValidationError",
98
112
  "ValidationErrorLocItem",
113
+ "document",
99
114
  "embeddings",
100
115
  "fetch",
101
116
  "search",
usecortex_ai/client.py CHANGED
@@ -5,6 +5,7 @@ import typing
5
5
  import httpx
6
6
  from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
7
7
  from .core.request_options import RequestOptions
8
+ from .document.client import AsyncDocumentClient, DocumentClient
8
9
  from .embeddings.client import AsyncEmbeddingsClient, EmbeddingsClient
9
10
  from .environment import CortexAIEnvironment
10
11
  from .fetch.client import AsyncFetchClient, FetchClient
@@ -89,6 +90,7 @@ class CortexAI:
89
90
  self.embeddings = EmbeddingsClient(client_wrapper=self._client_wrapper)
90
91
  self.user = UserClient(client_wrapper=self._client_wrapper)
91
92
  self.tenant = TenantClient(client_wrapper=self._client_wrapper)
93
+ self.document = DocumentClient(client_wrapper=self._client_wrapper)
92
94
 
93
95
  @property
94
96
  def with_raw_response(self) -> RawCortexAI:
@@ -196,6 +198,7 @@ class AsyncCortexAI:
196
198
  self.embeddings = AsyncEmbeddingsClient(client_wrapper=self._client_wrapper)
197
199
  self.user = AsyncUserClient(client_wrapper=self._client_wrapper)
198
200
  self.tenant = AsyncTenantClient(client_wrapper=self._client_wrapper)
201
+ self.document = AsyncDocumentClient(client_wrapper=self._client_wrapper)
199
202
 
200
203
  @property
201
204
  def with_raw_response(self) -> AsyncRawCortexAI:
@@ -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,139 @@
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.delete_sources import DeleteSources
8
+ from .raw_client import AsyncRawDocumentClient, RawDocumentClient
9
+
10
+ # this is used as the default value for optional parameters
11
+ OMIT = typing.cast(typing.Any, ...)
12
+
13
+
14
+ class DocumentClient:
15
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
16
+ self._raw_client = RawDocumentClient(client_wrapper=client_wrapper)
17
+
18
+ @property
19
+ def with_raw_response(self) -> RawDocumentClient:
20
+ """
21
+ Retrieves a raw implementation of this client that returns raw responses.
22
+
23
+ Returns
24
+ -------
25
+ RawDocumentClient
26
+ """
27
+ return self._raw_client
28
+
29
+ def delete(
30
+ self,
31
+ *,
32
+ tenant_id: str,
33
+ source_ids: typing.Sequence[str],
34
+ sub_tenant_id: typing.Optional[str] = OMIT,
35
+ request_options: typing.Optional[RequestOptions] = None,
36
+ ) -> DeleteSources:
37
+ """
38
+ Remove documents and content from your knowledge base.
39
+
40
+ This endpoint permanently deletes the specified sources from your knowledge base. Once deleted, the content will no longer be available for search or retrieval.
41
+
42
+ Use this carefully as the action cannot be undone. The system will confirm successful deletion of each source ID you specify.
43
+
44
+ Parameters
45
+ ----------
46
+ tenant_id : str
47
+ Unique identifier for the tenant/organization
48
+
49
+ source_ids : typing.Sequence[str]
50
+ List of source IDs to delete
51
+
52
+ sub_tenant_id : typing.Optional[str]
53
+ Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
54
+
55
+ request_options : typing.Optional[RequestOptions]
56
+ Request-specific configuration.
57
+
58
+ Returns
59
+ -------
60
+ DeleteSources
61
+ Successful Response
62
+
63
+ Examples
64
+ --------
65
+ from usecortex-ai import CortexAI
66
+
67
+ client = CortexAI(token="YOUR_TOKEN", )
68
+ client.document.delete(tenant_id='tenant_1234', source_ids=['CortexDoc1234', 'CortexDoc4567'], )
69
+ """
70
+ _response = self._raw_client.delete(
71
+ tenant_id=tenant_id, source_ids=source_ids, sub_tenant_id=sub_tenant_id, request_options=request_options
72
+ )
73
+ return _response.data
74
+
75
+
76
+ class AsyncDocumentClient:
77
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
78
+ self._raw_client = AsyncRawDocumentClient(client_wrapper=client_wrapper)
79
+
80
+ @property
81
+ def with_raw_response(self) -> AsyncRawDocumentClient:
82
+ """
83
+ Retrieves a raw implementation of this client that returns raw responses.
84
+
85
+ Returns
86
+ -------
87
+ AsyncRawDocumentClient
88
+ """
89
+ return self._raw_client
90
+
91
+ async def delete(
92
+ self,
93
+ *,
94
+ tenant_id: str,
95
+ source_ids: typing.Sequence[str],
96
+ sub_tenant_id: typing.Optional[str] = OMIT,
97
+ request_options: typing.Optional[RequestOptions] = None,
98
+ ) -> DeleteSources:
99
+ """
100
+ Remove documents and content from your knowledge base.
101
+
102
+ This endpoint permanently deletes the specified sources from your knowledge base. Once deleted, the content will no longer be available for search or retrieval.
103
+
104
+ Use this carefully as the action cannot be undone. The system will confirm successful deletion of each source ID you specify.
105
+
106
+ Parameters
107
+ ----------
108
+ tenant_id : str
109
+ Unique identifier for the tenant/organization
110
+
111
+ source_ids : typing.Sequence[str]
112
+ List of source IDs to delete
113
+
114
+ sub_tenant_id : typing.Optional[str]
115
+ Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
116
+
117
+ request_options : typing.Optional[RequestOptions]
118
+ Request-specific configuration.
119
+
120
+ Returns
121
+ -------
122
+ DeleteSources
123
+ Successful Response
124
+
125
+ Examples
126
+ --------
127
+ import asyncio
128
+
129
+ from usecortex-ai import AsyncCortexAI
130
+
131
+ client = AsyncCortexAI(token="YOUR_TOKEN", )
132
+ async def main() -> None:
133
+ await client.document.delete(tenant_id='tenant_1234', source_ids=['CortexDoc1234', 'CortexDoc4567'], )
134
+ asyncio.run(main())
135
+ """
136
+ _response = await self._raw_client.delete(
137
+ tenant_id=tenant_id, source_ids=source_ids, sub_tenant_id=sub_tenant_id, request_options=request_options
138
+ )
139
+ return _response.data
@@ -0,0 +1,312 @@
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.delete_sources import DeleteSources
20
+
21
+ # this is used as the default value for optional parameters
22
+ OMIT = typing.cast(typing.Any, ...)
23
+
24
+
25
+ class RawDocumentClient:
26
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
27
+ self._client_wrapper = client_wrapper
28
+
29
+ def delete(
30
+ self,
31
+ *,
32
+ tenant_id: str,
33
+ source_ids: typing.Sequence[str],
34
+ sub_tenant_id: typing.Optional[str] = OMIT,
35
+ request_options: typing.Optional[RequestOptions] = None,
36
+ ) -> HttpResponse[DeleteSources]:
37
+ """
38
+ Remove documents and content from your knowledge base.
39
+
40
+ This endpoint permanently deletes the specified sources from your knowledge base. Once deleted, the content will no longer be available for search or retrieval.
41
+
42
+ Use this carefully as the action cannot be undone. The system will confirm successful deletion of each source ID you specify.
43
+
44
+ Parameters
45
+ ----------
46
+ tenant_id : str
47
+ Unique identifier for the tenant/organization
48
+
49
+ source_ids : typing.Sequence[str]
50
+ List of source IDs to delete
51
+
52
+ sub_tenant_id : typing.Optional[str]
53
+ Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
54
+
55
+ request_options : typing.Optional[RequestOptions]
56
+ Request-specific configuration.
57
+
58
+ Returns
59
+ -------
60
+ HttpResponse[DeleteSources]
61
+ Successful Response
62
+ """
63
+ _response = self._client_wrapper.httpx_client.request(
64
+ "document/delete",
65
+ method="DELETE",
66
+ json={
67
+ "tenant_id": tenant_id,
68
+ "source_ids": source_ids,
69
+ "sub_tenant_id": sub_tenant_id,
70
+ },
71
+ headers={
72
+ "content-type": "application/json",
73
+ },
74
+ request_options=request_options,
75
+ omit=OMIT,
76
+ )
77
+ try:
78
+ if 200 <= _response.status_code < 300:
79
+ _data = typing.cast(
80
+ DeleteSources,
81
+ parse_obj_as(
82
+ type_=DeleteSources, # type: ignore
83
+ object_=_response.json(),
84
+ ),
85
+ )
86
+ return HttpResponse(response=_response, data=_data)
87
+ if _response.status_code == 400:
88
+ raise BadRequestError(
89
+ headers=dict(_response.headers),
90
+ body=typing.cast(
91
+ ActualErrorResponse,
92
+ parse_obj_as(
93
+ type_=ActualErrorResponse, # type: ignore
94
+ object_=_response.json(),
95
+ ),
96
+ ),
97
+ )
98
+ if _response.status_code == 401:
99
+ raise UnauthorizedError(
100
+ headers=dict(_response.headers),
101
+ body=typing.cast(
102
+ ActualErrorResponse,
103
+ parse_obj_as(
104
+ type_=ActualErrorResponse, # type: ignore
105
+ object_=_response.json(),
106
+ ),
107
+ ),
108
+ )
109
+ if _response.status_code == 403:
110
+ raise ForbiddenError(
111
+ headers=dict(_response.headers),
112
+ body=typing.cast(
113
+ ActualErrorResponse,
114
+ parse_obj_as(
115
+ type_=ActualErrorResponse, # type: ignore
116
+ object_=_response.json(),
117
+ ),
118
+ ),
119
+ )
120
+ if _response.status_code == 404:
121
+ raise NotFoundError(
122
+ headers=dict(_response.headers),
123
+ body=typing.cast(
124
+ ActualErrorResponse,
125
+ parse_obj_as(
126
+ type_=ActualErrorResponse, # type: ignore
127
+ object_=_response.json(),
128
+ ),
129
+ ),
130
+ )
131
+ if _response.status_code == 422:
132
+ raise UnprocessableEntityError(
133
+ headers=dict(_response.headers),
134
+ body=typing.cast(
135
+ typing.Optional[typing.Any],
136
+ parse_obj_as(
137
+ type_=typing.Optional[typing.Any], # type: ignore
138
+ object_=_response.json(),
139
+ ),
140
+ ),
141
+ )
142
+ if _response.status_code == 500:
143
+ raise InternalServerError(
144
+ headers=dict(_response.headers),
145
+ body=typing.cast(
146
+ ActualErrorResponse,
147
+ parse_obj_as(
148
+ type_=ActualErrorResponse, # type: ignore
149
+ object_=_response.json(),
150
+ ),
151
+ ),
152
+ )
153
+ if _response.status_code == 503:
154
+ raise ServiceUnavailableError(
155
+ headers=dict(_response.headers),
156
+ body=typing.cast(
157
+ ActualErrorResponse,
158
+ parse_obj_as(
159
+ type_=ActualErrorResponse, # type: ignore
160
+ object_=_response.json(),
161
+ ),
162
+ ),
163
+ )
164
+ _response_json = _response.json()
165
+ except JSONDecodeError:
166
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
167
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
168
+
169
+
170
+ class AsyncRawDocumentClient:
171
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
172
+ self._client_wrapper = client_wrapper
173
+
174
+ async def delete(
175
+ self,
176
+ *,
177
+ tenant_id: str,
178
+ source_ids: typing.Sequence[str],
179
+ sub_tenant_id: typing.Optional[str] = OMIT,
180
+ request_options: typing.Optional[RequestOptions] = None,
181
+ ) -> AsyncHttpResponse[DeleteSources]:
182
+ """
183
+ Remove documents and content from your knowledge base.
184
+
185
+ This endpoint permanently deletes the specified sources from your knowledge base. Once deleted, the content will no longer be available for search or retrieval.
186
+
187
+ Use this carefully as the action cannot be undone. The system will confirm successful deletion of each source ID you specify.
188
+
189
+ Parameters
190
+ ----------
191
+ tenant_id : str
192
+ Unique identifier for the tenant/organization
193
+
194
+ source_ids : typing.Sequence[str]
195
+ List of source IDs to delete
196
+
197
+ sub_tenant_id : typing.Optional[str]
198
+ Optional sub-tenant identifier used to organize data within a tenant. If omitted, the default sub-tenant created during tenant setup will be used.
199
+
200
+ request_options : typing.Optional[RequestOptions]
201
+ Request-specific configuration.
202
+
203
+ Returns
204
+ -------
205
+ AsyncHttpResponse[DeleteSources]
206
+ Successful Response
207
+ """
208
+ _response = await self._client_wrapper.httpx_client.request(
209
+ "document/delete",
210
+ method="DELETE",
211
+ json={
212
+ "tenant_id": tenant_id,
213
+ "source_ids": source_ids,
214
+ "sub_tenant_id": sub_tenant_id,
215
+ },
216
+ headers={
217
+ "content-type": "application/json",
218
+ },
219
+ request_options=request_options,
220
+ omit=OMIT,
221
+ )
222
+ try:
223
+ if 200 <= _response.status_code < 300:
224
+ _data = typing.cast(
225
+ DeleteSources,
226
+ parse_obj_as(
227
+ type_=DeleteSources, # type: ignore
228
+ object_=_response.json(),
229
+ ),
230
+ )
231
+ return AsyncHttpResponse(response=_response, data=_data)
232
+ if _response.status_code == 400:
233
+ raise BadRequestError(
234
+ headers=dict(_response.headers),
235
+ body=typing.cast(
236
+ ActualErrorResponse,
237
+ parse_obj_as(
238
+ type_=ActualErrorResponse, # type: ignore
239
+ object_=_response.json(),
240
+ ),
241
+ ),
242
+ )
243
+ if _response.status_code == 401:
244
+ raise UnauthorizedError(
245
+ headers=dict(_response.headers),
246
+ body=typing.cast(
247
+ ActualErrorResponse,
248
+ parse_obj_as(
249
+ type_=ActualErrorResponse, # type: ignore
250
+ object_=_response.json(),
251
+ ),
252
+ ),
253
+ )
254
+ if _response.status_code == 403:
255
+ raise ForbiddenError(
256
+ headers=dict(_response.headers),
257
+ body=typing.cast(
258
+ ActualErrorResponse,
259
+ parse_obj_as(
260
+ type_=ActualErrorResponse, # type: ignore
261
+ object_=_response.json(),
262
+ ),
263
+ ),
264
+ )
265
+ if _response.status_code == 404:
266
+ raise NotFoundError(
267
+ headers=dict(_response.headers),
268
+ body=typing.cast(
269
+ ActualErrorResponse,
270
+ parse_obj_as(
271
+ type_=ActualErrorResponse, # type: ignore
272
+ object_=_response.json(),
273
+ ),
274
+ ),
275
+ )
276
+ if _response.status_code == 422:
277
+ raise UnprocessableEntityError(
278
+ headers=dict(_response.headers),
279
+ body=typing.cast(
280
+ typing.Optional[typing.Any],
281
+ parse_obj_as(
282
+ type_=typing.Optional[typing.Any], # type: ignore
283
+ object_=_response.json(),
284
+ ),
285
+ ),
286
+ )
287
+ if _response.status_code == 500:
288
+ raise InternalServerError(
289
+ headers=dict(_response.headers),
290
+ body=typing.cast(
291
+ ActualErrorResponse,
292
+ parse_obj_as(
293
+ type_=ActualErrorResponse, # type: ignore
294
+ object_=_response.json(),
295
+ ),
296
+ ),
297
+ )
298
+ if _response.status_code == 503:
299
+ raise ServiceUnavailableError(
300
+ headers=dict(_response.headers),
301
+ body=typing.cast(
302
+ ActualErrorResponse,
303
+ parse_obj_as(
304
+ type_=ActualErrorResponse, # type: ignore
305
+ object_=_response.json(),
306
+ ),
307
+ ),
308
+ )
309
+ _response_json = _response.json()
310
+ except JSONDecodeError:
311
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
312
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)