isaacus 0.9.0__py3-none-any.whl → 0.10.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.
isaacus/_base_client.py CHANGED
@@ -9,6 +9,7 @@ import asyncio
9
9
  import inspect
10
10
  import logging
11
11
  import platform
12
+ import warnings
12
13
  import email.utils
13
14
  from types import TracebackType
14
15
  from random import random
@@ -51,9 +52,11 @@ from ._types import (
51
52
  ResponseT,
52
53
  AnyMapping,
53
54
  PostParser,
55
+ BinaryTypes,
54
56
  RequestFiles,
55
57
  HttpxSendArgs,
56
58
  RequestOptions,
59
+ AsyncBinaryTypes,
57
60
  HttpxRequestFiles,
58
61
  ModelBuilderProtocol,
59
62
  not_given,
@@ -83,6 +86,7 @@ from ._exceptions import (
83
86
  APIConnectionError,
84
87
  APIResponseValidationError,
85
88
  )
89
+ from ._utils._json import openapi_dumps
86
90
 
87
91
  log: logging.Logger = logging.getLogger(__name__)
88
92
 
@@ -477,8 +481,19 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
477
481
  retries_taken: int = 0,
478
482
  ) -> httpx.Request:
479
483
  if log.isEnabledFor(logging.DEBUG):
480
- log.debug("Request options: %s", model_dump(options, exclude_unset=True))
481
-
484
+ log.debug(
485
+ "Request options: %s",
486
+ model_dump(
487
+ options,
488
+ exclude_unset=True,
489
+ # Pydantic v1 can't dump every type we support in content, so we exclude it for now.
490
+ exclude={
491
+ "content",
492
+ }
493
+ if PYDANTIC_V1
494
+ else {},
495
+ ),
496
+ )
482
497
  kwargs: dict[str, Any] = {}
483
498
 
484
499
  json_data = options.json_data
@@ -532,10 +547,18 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
532
547
  is_body_allowed = options.method.lower() != "get"
533
548
 
534
549
  if is_body_allowed:
535
- if isinstance(json_data, bytes):
550
+ if options.content is not None and json_data is not None:
551
+ raise TypeError("Passing both `content` and `json_data` is not supported")
552
+ if options.content is not None and files is not None:
553
+ raise TypeError("Passing both `content` and `files` is not supported")
554
+ if options.content is not None:
555
+ kwargs["content"] = options.content
556
+ elif isinstance(json_data, bytes):
536
557
  kwargs["content"] = json_data
537
- else:
538
- kwargs["json"] = json_data if is_given(json_data) else None
558
+ elif not files:
559
+ # Don't set content when JSON is sent as multipart/form-data,
560
+ # since httpx's content param overrides other body arguments
561
+ kwargs["content"] = openapi_dumps(json_data) if is_given(json_data) and json_data is not None else None
539
562
  kwargs["files"] = files
540
563
  else:
541
564
  headers.pop("Content-Type", None)
@@ -1194,6 +1217,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1194
1217
  *,
1195
1218
  cast_to: Type[ResponseT],
1196
1219
  body: Body | None = None,
1220
+ content: BinaryTypes | None = None,
1197
1221
  options: RequestOptions = {},
1198
1222
  files: RequestFiles | None = None,
1199
1223
  stream: Literal[False] = False,
@@ -1206,6 +1230,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1206
1230
  *,
1207
1231
  cast_to: Type[ResponseT],
1208
1232
  body: Body | None = None,
1233
+ content: BinaryTypes | None = None,
1209
1234
  options: RequestOptions = {},
1210
1235
  files: RequestFiles | None = None,
1211
1236
  stream: Literal[True],
@@ -1219,6 +1244,7 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1219
1244
  *,
1220
1245
  cast_to: Type[ResponseT],
1221
1246
  body: Body | None = None,
1247
+ content: BinaryTypes | None = None,
1222
1248
  options: RequestOptions = {},
1223
1249
  files: RequestFiles | None = None,
1224
1250
  stream: bool,
@@ -1231,13 +1257,25 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1231
1257
  *,
1232
1258
  cast_to: Type[ResponseT],
1233
1259
  body: Body | None = None,
1260
+ content: BinaryTypes | None = None,
1234
1261
  options: RequestOptions = {},
1235
1262
  files: RequestFiles | None = None,
1236
1263
  stream: bool = False,
1237
1264
  stream_cls: type[_StreamT] | None = None,
1238
1265
  ) -> ResponseT | _StreamT:
1266
+ if body is not None and content is not None:
1267
+ raise TypeError("Passing both `body` and `content` is not supported")
1268
+ if files is not None and content is not None:
1269
+ raise TypeError("Passing both `files` and `content` is not supported")
1270
+ if isinstance(body, bytes):
1271
+ warnings.warn(
1272
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1273
+ "Please pass raw bytes via the `content` parameter instead.",
1274
+ DeprecationWarning,
1275
+ stacklevel=2,
1276
+ )
1239
1277
  opts = FinalRequestOptions.construct(
1240
- method="post", url=path, json_data=body, files=to_httpx_files(files), **options
1278
+ method="post", url=path, json_data=body, content=content, files=to_httpx_files(files), **options
1241
1279
  )
1242
1280
  return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
1243
1281
 
@@ -1247,9 +1285,24 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1247
1285
  *,
1248
1286
  cast_to: Type[ResponseT],
1249
1287
  body: Body | None = None,
1288
+ content: BinaryTypes | None = None,
1289
+ files: RequestFiles | None = None,
1250
1290
  options: RequestOptions = {},
1251
1291
  ) -> ResponseT:
1252
- opts = FinalRequestOptions.construct(method="patch", url=path, json_data=body, **options)
1292
+ if body is not None and content is not None:
1293
+ raise TypeError("Passing both `body` and `content` is not supported")
1294
+ if files is not None and content is not None:
1295
+ raise TypeError("Passing both `files` and `content` is not supported")
1296
+ if isinstance(body, bytes):
1297
+ warnings.warn(
1298
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1299
+ "Please pass raw bytes via the `content` parameter instead.",
1300
+ DeprecationWarning,
1301
+ stacklevel=2,
1302
+ )
1303
+ opts = FinalRequestOptions.construct(
1304
+ method="patch", url=path, json_data=body, content=content, files=to_httpx_files(files), **options
1305
+ )
1253
1306
  return self.request(cast_to, opts)
1254
1307
 
1255
1308
  def put(
@@ -1258,11 +1311,23 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1258
1311
  *,
1259
1312
  cast_to: Type[ResponseT],
1260
1313
  body: Body | None = None,
1314
+ content: BinaryTypes | None = None,
1261
1315
  files: RequestFiles | None = None,
1262
1316
  options: RequestOptions = {},
1263
1317
  ) -> ResponseT:
1318
+ if body is not None and content is not None:
1319
+ raise TypeError("Passing both `body` and `content` is not supported")
1320
+ if files is not None and content is not None:
1321
+ raise TypeError("Passing both `files` and `content` is not supported")
1322
+ if isinstance(body, bytes):
1323
+ warnings.warn(
1324
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1325
+ "Please pass raw bytes via the `content` parameter instead.",
1326
+ DeprecationWarning,
1327
+ stacklevel=2,
1328
+ )
1264
1329
  opts = FinalRequestOptions.construct(
1265
- method="put", url=path, json_data=body, files=to_httpx_files(files), **options
1330
+ method="put", url=path, json_data=body, content=content, files=to_httpx_files(files), **options
1266
1331
  )
1267
1332
  return self.request(cast_to, opts)
1268
1333
 
@@ -1272,9 +1337,19 @@ class SyncAPIClient(BaseClient[httpx.Client, Stream[Any]]):
1272
1337
  *,
1273
1338
  cast_to: Type[ResponseT],
1274
1339
  body: Body | None = None,
1340
+ content: BinaryTypes | None = None,
1275
1341
  options: RequestOptions = {},
1276
1342
  ) -> ResponseT:
1277
- opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, **options)
1343
+ if body is not None and content is not None:
1344
+ raise TypeError("Passing both `body` and `content` is not supported")
1345
+ if isinstance(body, bytes):
1346
+ warnings.warn(
1347
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1348
+ "Please pass raw bytes via the `content` parameter instead.",
1349
+ DeprecationWarning,
1350
+ stacklevel=2,
1351
+ )
1352
+ opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, content=content, **options)
1278
1353
  return self.request(cast_to, opts)
1279
1354
 
1280
1355
  def get_api_list(
@@ -1714,6 +1789,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1714
1789
  *,
1715
1790
  cast_to: Type[ResponseT],
1716
1791
  body: Body | None = None,
1792
+ content: AsyncBinaryTypes | None = None,
1717
1793
  files: RequestFiles | None = None,
1718
1794
  options: RequestOptions = {},
1719
1795
  stream: Literal[False] = False,
@@ -1726,6 +1802,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1726
1802
  *,
1727
1803
  cast_to: Type[ResponseT],
1728
1804
  body: Body | None = None,
1805
+ content: AsyncBinaryTypes | None = None,
1729
1806
  files: RequestFiles | None = None,
1730
1807
  options: RequestOptions = {},
1731
1808
  stream: Literal[True],
@@ -1739,6 +1816,7 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1739
1816
  *,
1740
1817
  cast_to: Type[ResponseT],
1741
1818
  body: Body | None = None,
1819
+ content: AsyncBinaryTypes | None = None,
1742
1820
  files: RequestFiles | None = None,
1743
1821
  options: RequestOptions = {},
1744
1822
  stream: bool,
@@ -1751,13 +1829,25 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1751
1829
  *,
1752
1830
  cast_to: Type[ResponseT],
1753
1831
  body: Body | None = None,
1832
+ content: AsyncBinaryTypes | None = None,
1754
1833
  files: RequestFiles | None = None,
1755
1834
  options: RequestOptions = {},
1756
1835
  stream: bool = False,
1757
1836
  stream_cls: type[_AsyncStreamT] | None = None,
1758
1837
  ) -> ResponseT | _AsyncStreamT:
1838
+ if body is not None and content is not None:
1839
+ raise TypeError("Passing both `body` and `content` is not supported")
1840
+ if files is not None and content is not None:
1841
+ raise TypeError("Passing both `files` and `content` is not supported")
1842
+ if isinstance(body, bytes):
1843
+ warnings.warn(
1844
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1845
+ "Please pass raw bytes via the `content` parameter instead.",
1846
+ DeprecationWarning,
1847
+ stacklevel=2,
1848
+ )
1759
1849
  opts = FinalRequestOptions.construct(
1760
- method="post", url=path, json_data=body, files=await async_to_httpx_files(files), **options
1850
+ method="post", url=path, json_data=body, content=content, files=await async_to_httpx_files(files), **options
1761
1851
  )
1762
1852
  return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)
1763
1853
 
@@ -1767,9 +1857,29 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1767
1857
  *,
1768
1858
  cast_to: Type[ResponseT],
1769
1859
  body: Body | None = None,
1860
+ content: AsyncBinaryTypes | None = None,
1861
+ files: RequestFiles | None = None,
1770
1862
  options: RequestOptions = {},
1771
1863
  ) -> ResponseT:
1772
- opts = FinalRequestOptions.construct(method="patch", url=path, json_data=body, **options)
1864
+ if body is not None and content is not None:
1865
+ raise TypeError("Passing both `body` and `content` is not supported")
1866
+ if files is not None and content is not None:
1867
+ raise TypeError("Passing both `files` and `content` is not supported")
1868
+ if isinstance(body, bytes):
1869
+ warnings.warn(
1870
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1871
+ "Please pass raw bytes via the `content` parameter instead.",
1872
+ DeprecationWarning,
1873
+ stacklevel=2,
1874
+ )
1875
+ opts = FinalRequestOptions.construct(
1876
+ method="patch",
1877
+ url=path,
1878
+ json_data=body,
1879
+ content=content,
1880
+ files=await async_to_httpx_files(files),
1881
+ **options,
1882
+ )
1773
1883
  return await self.request(cast_to, opts)
1774
1884
 
1775
1885
  async def put(
@@ -1778,11 +1888,23 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1778
1888
  *,
1779
1889
  cast_to: Type[ResponseT],
1780
1890
  body: Body | None = None,
1891
+ content: AsyncBinaryTypes | None = None,
1781
1892
  files: RequestFiles | None = None,
1782
1893
  options: RequestOptions = {},
1783
1894
  ) -> ResponseT:
1895
+ if body is not None and content is not None:
1896
+ raise TypeError("Passing both `body` and `content` is not supported")
1897
+ if files is not None and content is not None:
1898
+ raise TypeError("Passing both `files` and `content` is not supported")
1899
+ if isinstance(body, bytes):
1900
+ warnings.warn(
1901
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1902
+ "Please pass raw bytes via the `content` parameter instead.",
1903
+ DeprecationWarning,
1904
+ stacklevel=2,
1905
+ )
1784
1906
  opts = FinalRequestOptions.construct(
1785
- method="put", url=path, json_data=body, files=await async_to_httpx_files(files), **options
1907
+ method="put", url=path, json_data=body, content=content, files=await async_to_httpx_files(files), **options
1786
1908
  )
1787
1909
  return await self.request(cast_to, opts)
1788
1910
 
@@ -1792,9 +1914,19 @@ class AsyncAPIClient(BaseClient[httpx.AsyncClient, AsyncStream[Any]]):
1792
1914
  *,
1793
1915
  cast_to: Type[ResponseT],
1794
1916
  body: Body | None = None,
1917
+ content: AsyncBinaryTypes | None = None,
1795
1918
  options: RequestOptions = {},
1796
1919
  ) -> ResponseT:
1797
- opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, **options)
1920
+ if body is not None and content is not None:
1921
+ raise TypeError("Passing both `body` and `content` is not supported")
1922
+ if isinstance(body, bytes):
1923
+ warnings.warn(
1924
+ "Passing raw bytes as `body` is deprecated and will be removed in a future version. "
1925
+ "Please pass raw bytes via the `content` parameter instead.",
1926
+ DeprecationWarning,
1927
+ stacklevel=2,
1928
+ )
1929
+ opts = FinalRequestOptions.construct(method="delete", url=path, json_data=body, content=content, **options)
1798
1930
  return await self.request(cast_to, opts)
1799
1931
 
1800
1932
  def get_api_list(
isaacus/_client.py CHANGED
@@ -3,7 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import os
6
- from typing import Any, Mapping
6
+ from typing import TYPE_CHECKING, Any, Mapping
7
7
  from typing_extensions import Self, override
8
8
 
9
9
  import httpx
@@ -20,8 +20,8 @@ from ._types import (
20
20
  not_given,
21
21
  )
22
22
  from ._utils import is_given, get_async_library
23
+ from ._compat import cached_property
23
24
  from ._version import __version__
24
- from .resources import embeddings, rerankings
25
25
  from ._streaming import Stream as Stream, AsyncStream as AsyncStream
26
26
  from ._exceptions import IsaacusError, APIStatusError
27
27
  from ._base_client import (
@@ -29,20 +29,19 @@ from ._base_client import (
29
29
  SyncAPIClient,
30
30
  AsyncAPIClient,
31
31
  )
32
- from .resources.extractions import extractions
33
- from .resources.classifications import classifications
32
+
33
+ if TYPE_CHECKING:
34
+ from .resources import embeddings, rerankings, enrichments, extractions, classifications
35
+ from .resources.embeddings import EmbeddingsResource, AsyncEmbeddingsResource
36
+ from .resources.rerankings import RerankingsResource, AsyncRerankingsResource
37
+ from .resources.enrichments import EnrichmentsResource, AsyncEnrichmentsResource
38
+ from .resources.extractions.extractions import ExtractionsResource, AsyncExtractionsResource
39
+ from .resources.classifications.classifications import ClassificationsResource, AsyncClassificationsResource
34
40
 
35
41
  __all__ = ["Timeout", "Transport", "ProxiesTypes", "RequestOptions", "Isaacus", "AsyncIsaacus", "Client", "AsyncClient"]
36
42
 
37
43
 
38
44
  class Isaacus(SyncAPIClient):
39
- embeddings: embeddings.EmbeddingsResource
40
- classifications: classifications.ClassificationsResource
41
- rerankings: rerankings.RerankingsResource
42
- extractions: extractions.ExtractionsResource
43
- with_raw_response: IsaacusWithRawResponse
44
- with_streaming_response: IsaacusWithStreamedResponse
45
-
46
45
  # client options
47
46
  api_key: str
48
47
 
@@ -97,12 +96,43 @@ class Isaacus(SyncAPIClient):
97
96
  _strict_response_validation=_strict_response_validation,
98
97
  )
99
98
 
100
- self.embeddings = embeddings.EmbeddingsResource(self)
101
- self.classifications = classifications.ClassificationsResource(self)
102
- self.rerankings = rerankings.RerankingsResource(self)
103
- self.extractions = extractions.ExtractionsResource(self)
104
- self.with_raw_response = IsaacusWithRawResponse(self)
105
- self.with_streaming_response = IsaacusWithStreamedResponse(self)
99
+ @cached_property
100
+ def embeddings(self) -> EmbeddingsResource:
101
+ from .resources.embeddings import EmbeddingsResource
102
+
103
+ return EmbeddingsResource(self)
104
+
105
+ @cached_property
106
+ def classifications(self) -> ClassificationsResource:
107
+ from .resources.classifications import ClassificationsResource
108
+
109
+ return ClassificationsResource(self)
110
+
111
+ @cached_property
112
+ def rerankings(self) -> RerankingsResource:
113
+ from .resources.rerankings import RerankingsResource
114
+
115
+ return RerankingsResource(self)
116
+
117
+ @cached_property
118
+ def extractions(self) -> ExtractionsResource:
119
+ from .resources.extractions import ExtractionsResource
120
+
121
+ return ExtractionsResource(self)
122
+
123
+ @cached_property
124
+ def enrichments(self) -> EnrichmentsResource:
125
+ from .resources.enrichments import EnrichmentsResource
126
+
127
+ return EnrichmentsResource(self)
128
+
129
+ @cached_property
130
+ def with_raw_response(self) -> IsaacusWithRawResponse:
131
+ return IsaacusWithRawResponse(self)
132
+
133
+ @cached_property
134
+ def with_streaming_response(self) -> IsaacusWithStreamedResponse:
135
+ return IsaacusWithStreamedResponse(self)
106
136
 
107
137
  @property
108
138
  @override
@@ -210,13 +240,6 @@ class Isaacus(SyncAPIClient):
210
240
 
211
241
 
212
242
  class AsyncIsaacus(AsyncAPIClient):
213
- embeddings: embeddings.AsyncEmbeddingsResource
214
- classifications: classifications.AsyncClassificationsResource
215
- rerankings: rerankings.AsyncRerankingsResource
216
- extractions: extractions.AsyncExtractionsResource
217
- with_raw_response: AsyncIsaacusWithRawResponse
218
- with_streaming_response: AsyncIsaacusWithStreamedResponse
219
-
220
243
  # client options
221
244
  api_key: str
222
245
 
@@ -271,12 +294,43 @@ class AsyncIsaacus(AsyncAPIClient):
271
294
  _strict_response_validation=_strict_response_validation,
272
295
  )
273
296
 
274
- self.embeddings = embeddings.AsyncEmbeddingsResource(self)
275
- self.classifications = classifications.AsyncClassificationsResource(self)
276
- self.rerankings = rerankings.AsyncRerankingsResource(self)
277
- self.extractions = extractions.AsyncExtractionsResource(self)
278
- self.with_raw_response = AsyncIsaacusWithRawResponse(self)
279
- self.with_streaming_response = AsyncIsaacusWithStreamedResponse(self)
297
+ @cached_property
298
+ def embeddings(self) -> AsyncEmbeddingsResource:
299
+ from .resources.embeddings import AsyncEmbeddingsResource
300
+
301
+ return AsyncEmbeddingsResource(self)
302
+
303
+ @cached_property
304
+ def classifications(self) -> AsyncClassificationsResource:
305
+ from .resources.classifications import AsyncClassificationsResource
306
+
307
+ return AsyncClassificationsResource(self)
308
+
309
+ @cached_property
310
+ def rerankings(self) -> AsyncRerankingsResource:
311
+ from .resources.rerankings import AsyncRerankingsResource
312
+
313
+ return AsyncRerankingsResource(self)
314
+
315
+ @cached_property
316
+ def extractions(self) -> AsyncExtractionsResource:
317
+ from .resources.extractions import AsyncExtractionsResource
318
+
319
+ return AsyncExtractionsResource(self)
320
+
321
+ @cached_property
322
+ def enrichments(self) -> AsyncEnrichmentsResource:
323
+ from .resources.enrichments import AsyncEnrichmentsResource
324
+
325
+ return AsyncEnrichmentsResource(self)
326
+
327
+ @cached_property
328
+ def with_raw_response(self) -> AsyncIsaacusWithRawResponse:
329
+ return AsyncIsaacusWithRawResponse(self)
330
+
331
+ @cached_property
332
+ def with_streaming_response(self) -> AsyncIsaacusWithStreamedResponse:
333
+ return AsyncIsaacusWithStreamedResponse(self)
280
334
 
281
335
  @property
282
336
  @override
@@ -384,35 +438,151 @@ class AsyncIsaacus(AsyncAPIClient):
384
438
 
385
439
 
386
440
  class IsaacusWithRawResponse:
441
+ _client: Isaacus
442
+
387
443
  def __init__(self, client: Isaacus) -> None:
388
- self.embeddings = embeddings.EmbeddingsResourceWithRawResponse(client.embeddings)
389
- self.classifications = classifications.ClassificationsResourceWithRawResponse(client.classifications)
390
- self.rerankings = rerankings.RerankingsResourceWithRawResponse(client.rerankings)
391
- self.extractions = extractions.ExtractionsResourceWithRawResponse(client.extractions)
444
+ self._client = client
445
+
446
+ @cached_property
447
+ def embeddings(self) -> embeddings.EmbeddingsResourceWithRawResponse:
448
+ from .resources.embeddings import EmbeddingsResourceWithRawResponse
449
+
450
+ return EmbeddingsResourceWithRawResponse(self._client.embeddings)
451
+
452
+ @cached_property
453
+ def classifications(self) -> classifications.ClassificationsResourceWithRawResponse:
454
+ from .resources.classifications import ClassificationsResourceWithRawResponse
455
+
456
+ return ClassificationsResourceWithRawResponse(self._client.classifications)
457
+
458
+ @cached_property
459
+ def rerankings(self) -> rerankings.RerankingsResourceWithRawResponse:
460
+ from .resources.rerankings import RerankingsResourceWithRawResponse
461
+
462
+ return RerankingsResourceWithRawResponse(self._client.rerankings)
463
+
464
+ @cached_property
465
+ def extractions(self) -> extractions.ExtractionsResourceWithRawResponse:
466
+ from .resources.extractions import ExtractionsResourceWithRawResponse
467
+
468
+ return ExtractionsResourceWithRawResponse(self._client.extractions)
469
+
470
+ @cached_property
471
+ def enrichments(self) -> enrichments.EnrichmentsResourceWithRawResponse:
472
+ from .resources.enrichments import EnrichmentsResourceWithRawResponse
473
+
474
+ return EnrichmentsResourceWithRawResponse(self._client.enrichments)
392
475
 
393
476
 
394
477
  class AsyncIsaacusWithRawResponse:
478
+ _client: AsyncIsaacus
479
+
395
480
  def __init__(self, client: AsyncIsaacus) -> None:
396
- self.embeddings = embeddings.AsyncEmbeddingsResourceWithRawResponse(client.embeddings)
397
- self.classifications = classifications.AsyncClassificationsResourceWithRawResponse(client.classifications)
398
- self.rerankings = rerankings.AsyncRerankingsResourceWithRawResponse(client.rerankings)
399
- self.extractions = extractions.AsyncExtractionsResourceWithRawResponse(client.extractions)
481
+ self._client = client
482
+
483
+ @cached_property
484
+ def embeddings(self) -> embeddings.AsyncEmbeddingsResourceWithRawResponse:
485
+ from .resources.embeddings import AsyncEmbeddingsResourceWithRawResponse
486
+
487
+ return AsyncEmbeddingsResourceWithRawResponse(self._client.embeddings)
488
+
489
+ @cached_property
490
+ def classifications(self) -> classifications.AsyncClassificationsResourceWithRawResponse:
491
+ from .resources.classifications import AsyncClassificationsResourceWithRawResponse
492
+
493
+ return AsyncClassificationsResourceWithRawResponse(self._client.classifications)
494
+
495
+ @cached_property
496
+ def rerankings(self) -> rerankings.AsyncRerankingsResourceWithRawResponse:
497
+ from .resources.rerankings import AsyncRerankingsResourceWithRawResponse
498
+
499
+ return AsyncRerankingsResourceWithRawResponse(self._client.rerankings)
500
+
501
+ @cached_property
502
+ def extractions(self) -> extractions.AsyncExtractionsResourceWithRawResponse:
503
+ from .resources.extractions import AsyncExtractionsResourceWithRawResponse
504
+
505
+ return AsyncExtractionsResourceWithRawResponse(self._client.extractions)
506
+
507
+ @cached_property
508
+ def enrichments(self) -> enrichments.AsyncEnrichmentsResourceWithRawResponse:
509
+ from .resources.enrichments import AsyncEnrichmentsResourceWithRawResponse
510
+
511
+ return AsyncEnrichmentsResourceWithRawResponse(self._client.enrichments)
400
512
 
401
513
 
402
514
  class IsaacusWithStreamedResponse:
515
+ _client: Isaacus
516
+
403
517
  def __init__(self, client: Isaacus) -> None:
404
- self.embeddings = embeddings.EmbeddingsResourceWithStreamingResponse(client.embeddings)
405
- self.classifications = classifications.ClassificationsResourceWithStreamingResponse(client.classifications)
406
- self.rerankings = rerankings.RerankingsResourceWithStreamingResponse(client.rerankings)
407
- self.extractions = extractions.ExtractionsResourceWithStreamingResponse(client.extractions)
518
+ self._client = client
519
+
520
+ @cached_property
521
+ def embeddings(self) -> embeddings.EmbeddingsResourceWithStreamingResponse:
522
+ from .resources.embeddings import EmbeddingsResourceWithStreamingResponse
523
+
524
+ return EmbeddingsResourceWithStreamingResponse(self._client.embeddings)
525
+
526
+ @cached_property
527
+ def classifications(self) -> classifications.ClassificationsResourceWithStreamingResponse:
528
+ from .resources.classifications import ClassificationsResourceWithStreamingResponse
529
+
530
+ return ClassificationsResourceWithStreamingResponse(self._client.classifications)
531
+
532
+ @cached_property
533
+ def rerankings(self) -> rerankings.RerankingsResourceWithStreamingResponse:
534
+ from .resources.rerankings import RerankingsResourceWithStreamingResponse
535
+
536
+ return RerankingsResourceWithStreamingResponse(self._client.rerankings)
537
+
538
+ @cached_property
539
+ def extractions(self) -> extractions.ExtractionsResourceWithStreamingResponse:
540
+ from .resources.extractions import ExtractionsResourceWithStreamingResponse
541
+
542
+ return ExtractionsResourceWithStreamingResponse(self._client.extractions)
543
+
544
+ @cached_property
545
+ def enrichments(self) -> enrichments.EnrichmentsResourceWithStreamingResponse:
546
+ from .resources.enrichments import EnrichmentsResourceWithStreamingResponse
547
+
548
+ return EnrichmentsResourceWithStreamingResponse(self._client.enrichments)
408
549
 
409
550
 
410
551
  class AsyncIsaacusWithStreamedResponse:
552
+ _client: AsyncIsaacus
553
+
411
554
  def __init__(self, client: AsyncIsaacus) -> None:
412
- self.embeddings = embeddings.AsyncEmbeddingsResourceWithStreamingResponse(client.embeddings)
413
- self.classifications = classifications.AsyncClassificationsResourceWithStreamingResponse(client.classifications)
414
- self.rerankings = rerankings.AsyncRerankingsResourceWithStreamingResponse(client.rerankings)
415
- self.extractions = extractions.AsyncExtractionsResourceWithStreamingResponse(client.extractions)
555
+ self._client = client
556
+
557
+ @cached_property
558
+ def embeddings(self) -> embeddings.AsyncEmbeddingsResourceWithStreamingResponse:
559
+ from .resources.embeddings import AsyncEmbeddingsResourceWithStreamingResponse
560
+
561
+ return AsyncEmbeddingsResourceWithStreamingResponse(self._client.embeddings)
562
+
563
+ @cached_property
564
+ def classifications(self) -> classifications.AsyncClassificationsResourceWithStreamingResponse:
565
+ from .resources.classifications import AsyncClassificationsResourceWithStreamingResponse
566
+
567
+ return AsyncClassificationsResourceWithStreamingResponse(self._client.classifications)
568
+
569
+ @cached_property
570
+ def rerankings(self) -> rerankings.AsyncRerankingsResourceWithStreamingResponse:
571
+ from .resources.rerankings import AsyncRerankingsResourceWithStreamingResponse
572
+
573
+ return AsyncRerankingsResourceWithStreamingResponse(self._client.rerankings)
574
+
575
+ @cached_property
576
+ def extractions(self) -> extractions.AsyncExtractionsResourceWithStreamingResponse:
577
+ from .resources.extractions import AsyncExtractionsResourceWithStreamingResponse
578
+
579
+ return AsyncExtractionsResourceWithStreamingResponse(self._client.extractions)
580
+
581
+ @cached_property
582
+ def enrichments(self) -> enrichments.AsyncEnrichmentsResourceWithStreamingResponse:
583
+ from .resources.enrichments import AsyncEnrichmentsResourceWithStreamingResponse
584
+
585
+ return AsyncEnrichmentsResourceWithStreamingResponse(self._client.enrichments)
416
586
 
417
587
 
418
588
  Client = Isaacus
isaacus/_compat.py CHANGED
@@ -139,6 +139,7 @@ def model_dump(
139
139
  exclude_defaults: bool = False,
140
140
  warnings: bool = True,
141
141
  mode: Literal["json", "python"] = "python",
142
+ by_alias: bool | None = None,
142
143
  ) -> dict[str, Any]:
143
144
  if (not PYDANTIC_V1) or hasattr(model, "model_dump"):
144
145
  return model.model_dump(
@@ -148,13 +149,12 @@ def model_dump(
148
149
  exclude_defaults=exclude_defaults,
149
150
  # warnings are not supported in Pydantic v1
150
151
  warnings=True if PYDANTIC_V1 else warnings,
152
+ by_alias=by_alias,
151
153
  )
152
154
  return cast(
153
155
  "dict[str, Any]",
154
156
  model.dict( # pyright: ignore[reportDeprecated, reportUnnecessaryCast]
155
- exclude=exclude,
156
- exclude_unset=exclude_unset,
157
- exclude_defaults=exclude_defaults,
157
+ exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, by_alias=bool(by_alias)
158
158
  ),
159
159
  )
160
160