mixpeek 0.6.7__tar.gz → 0.6.8__tar.gz
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.
- {mixpeek-0.6.7 → mixpeek-0.6.8}/PKG-INFO +1 -1
- {mixpeek-0.6.7 → mixpeek-0.6.8}/pyproject.toml +1 -1
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/base_client.py +89 -63
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/core/__init__.py +2 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/core/client_wrapper.py +1 -1
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/core/jsonable_encoder.py +5 -9
- mixpeek-0.6.8/src/mixpeek/core/pydantic_utilities.py +12 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/pipeline/client.py +55 -47
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/storage/client.py +19 -19
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/storage/sample/client.py +37 -33
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/api_key.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/audio_params.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/configs_response.py +6 -10
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/connection.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/csv_params.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/destination.py +6 -10
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/embedding_response.py +4 -8
- mixpeek-0.6.7/src/mixpeek/types/txt_params.py → mixpeek-0.6.8/src/mixpeek/types/error_message.py +4 -6
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/error_response.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/extract_response.py +4 -8
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/generation_response.py +4 -8
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/html_params.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/http_validation_error.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/image_params.py +4 -8
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/message.py +5 -9
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/metadata.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/model.py +5 -9
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/pdf_params.py +4 -8
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/pipeline_response.py +6 -10
- mixpeek-0.6.7/src/mixpeek/types/error_message.py → mixpeek-0.6.8/src/mixpeek/types/pipeline_task_response.py +7 -8
- mixpeek-0.6.8/src/mixpeek/types/ppt_params.py +23 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/pptx_params.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/settings.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/source.py +6 -10
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/source_destination_mapping.py +6 -10
- mixpeek-0.6.8/src/mixpeek/types/txt_params.py +23 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/user.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/validation_error.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/video_params.py +3 -7
- mixpeek-0.6.7/src/mixpeek/types/ppt_params.py → mixpeek-0.6.8/src/mixpeek/types/workflow_code_response.py +4 -6
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/workflow_response.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/workflow_settings.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/xlsx_params.py +3 -7
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/user/client.py +37 -33
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/workflow/client.py +55 -47
- mixpeek-0.6.7/src/mixpeek/types/pipeline_task_response.py +0 -32
- mixpeek-0.6.7/src/mixpeek/types/workflow_code_response.py +0 -29
- {mixpeek-0.6.7 → mixpeek-0.6.8}/LICENSE +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/README.md +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/__init__.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/client.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/core/api_error.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/core/datetime_utils.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/core/file.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/core/http_client.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/core/remove_none_from_dict.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/core/request_options.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/environment.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/errors/__init__.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/errors/bad_request_error.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/errors/forbidden_error.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/errors/internal_server_error.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/errors/not_found_error.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/errors/unauthorized_error.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/errors/unprocessable_entity_error.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/pipeline/__init__.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/py.typed +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/storage/__init__.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/storage/sample/__init__.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/__init__.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/connection_engine.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/field_type.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/modality.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/models.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/types/validation_error_loc_item.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/user/__init__.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/version.py +0 -0
- {mixpeek-0.6.7 → mixpeek-0.6.8}/src/mixpeek/workflow/__init__.py +0 -0
@@ -10,6 +10,7 @@ import httpx
|
|
10
10
|
from .core.api_error import ApiError
|
11
11
|
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
12
12
|
from .core.jsonable_encoder import jsonable_encoder
|
13
|
+
from .core.pydantic_utilities import pydantic_v1
|
13
14
|
from .core.remove_none_from_dict import remove_none_from_dict
|
14
15
|
from .core.request_options import RequestOptions
|
15
16
|
from .environment import MixpeekEnvironment
|
@@ -45,11 +46,6 @@ from .types.xlsx_params import XlsxParams
|
|
45
46
|
from .user.client import AsyncUserClient, UserClient
|
46
47
|
from .workflow.client import AsyncWorkflowClient, WorkflowClient
|
47
48
|
|
48
|
-
try:
|
49
|
-
import pydantic.v1 as pydantic # type: ignore
|
50
|
-
except ImportError:
|
51
|
-
import pydantic # type: ignore
|
52
|
-
|
53
49
|
# this is used as the default value for optional parameters
|
54
50
|
OMIT = typing.cast(typing.Any, ...)
|
55
51
|
|
@@ -73,6 +69,8 @@ class BaseMixpeek:
|
|
73
69
|
|
74
70
|
- timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set.
|
75
71
|
|
72
|
+
- follow_redirects: typing.Optional[bool]. Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
73
|
+
|
76
74
|
- httpx_client: typing.Optional[httpx.Client]. The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
77
75
|
---
|
78
76
|
from mixpeek.client import Mixpeek
|
@@ -93,6 +91,7 @@ class BaseMixpeek:
|
|
93
91
|
index_id: typing.Optional[str] = None,
|
94
92
|
api_key: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv("MIXPEEK_API_KEY"),
|
95
93
|
timeout: typing.Optional[float] = None,
|
94
|
+
follow_redirects: typing.Optional[bool] = True,
|
96
95
|
httpx_client: typing.Optional[httpx.Client] = None,
|
97
96
|
):
|
98
97
|
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
|
@@ -105,7 +104,11 @@ class BaseMixpeek:
|
|
105
104
|
authorization=authorization,
|
106
105
|
index_id=index_id,
|
107
106
|
api_key=api_key,
|
108
|
-
httpx_client=
|
107
|
+
httpx_client=httpx_client
|
108
|
+
if httpx_client is not None
|
109
|
+
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
110
|
+
if follow_redirects is not None
|
111
|
+
else httpx.Client(timeout=_defaulted_timeout),
|
109
112
|
timeout=_defaulted_timeout,
|
110
113
|
)
|
111
114
|
self.user = UserClient(client_wrapper=self._client_wrapper)
|
@@ -244,19 +247,21 @@ class BaseMixpeek:
|
|
244
247
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
245
248
|
)
|
246
249
|
if 200 <= _response.status_code < 300:
|
247
|
-
return
|
250
|
+
return pydantic_v1.parse_obj_as(ExtractResponse, _response.json()) # type: ignore
|
248
251
|
if _response.status_code == 400:
|
249
|
-
raise BadRequestError(
|
252
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
250
253
|
if _response.status_code == 401:
|
251
|
-
raise UnauthorizedError(
|
254
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
252
255
|
if _response.status_code == 403:
|
253
|
-
raise ForbiddenError(
|
256
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
254
257
|
if _response.status_code == 404:
|
255
|
-
raise NotFoundError(
|
258
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
256
259
|
if _response.status_code == 422:
|
257
|
-
raise UnprocessableEntityError(
|
260
|
+
raise UnprocessableEntityError(
|
261
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
262
|
+
)
|
258
263
|
if _response.status_code == 500:
|
259
|
-
raise InternalServerError(
|
264
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
260
265
|
try:
|
261
266
|
_response_json = _response.json()
|
262
267
|
except JSONDecodeError:
|
@@ -342,19 +347,21 @@ class BaseMixpeek:
|
|
342
347
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
343
348
|
)
|
344
349
|
if 200 <= _response.status_code < 300:
|
345
|
-
return
|
350
|
+
return pydantic_v1.parse_obj_as(GenerationResponse, _response.json()) # type: ignore
|
346
351
|
if _response.status_code == 400:
|
347
|
-
raise BadRequestError(
|
352
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
348
353
|
if _response.status_code == 401:
|
349
|
-
raise UnauthorizedError(
|
354
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
350
355
|
if _response.status_code == 403:
|
351
|
-
raise ForbiddenError(
|
356
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
352
357
|
if _response.status_code == 404:
|
353
|
-
raise NotFoundError(
|
358
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
354
359
|
if _response.status_code == 422:
|
355
|
-
raise UnprocessableEntityError(
|
360
|
+
raise UnprocessableEntityError(
|
361
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
362
|
+
)
|
356
363
|
if _response.status_code == 500:
|
357
|
-
raise InternalServerError(
|
364
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
358
365
|
try:
|
359
366
|
_response_json = _response.json()
|
360
367
|
except JSONDecodeError:
|
@@ -417,19 +424,21 @@ class BaseMixpeek:
|
|
417
424
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
418
425
|
)
|
419
426
|
if 200 <= _response.status_code < 300:
|
420
|
-
return
|
427
|
+
return pydantic_v1.parse_obj_as(ConfigsResponse, _response.json()) # type: ignore
|
421
428
|
if _response.status_code == 400:
|
422
|
-
raise BadRequestError(
|
429
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
423
430
|
if _response.status_code == 401:
|
424
|
-
raise UnauthorizedError(
|
431
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
425
432
|
if _response.status_code == 403:
|
426
|
-
raise ForbiddenError(
|
433
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
427
434
|
if _response.status_code == 404:
|
428
|
-
raise NotFoundError(
|
435
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
429
436
|
if _response.status_code == 422:
|
430
|
-
raise UnprocessableEntityError(
|
437
|
+
raise UnprocessableEntityError(
|
438
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
439
|
+
)
|
431
440
|
if _response.status_code == 500:
|
432
|
-
raise InternalServerError(
|
441
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
433
442
|
try:
|
434
443
|
_response_json = _response.json()
|
435
444
|
except JSONDecodeError:
|
@@ -497,19 +506,21 @@ class BaseMixpeek:
|
|
497
506
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
498
507
|
)
|
499
508
|
if 200 <= _response.status_code < 300:
|
500
|
-
return
|
509
|
+
return pydantic_v1.parse_obj_as(EmbeddingResponse, _response.json()) # type: ignore
|
501
510
|
if _response.status_code == 400:
|
502
|
-
raise BadRequestError(
|
511
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
503
512
|
if _response.status_code == 401:
|
504
|
-
raise UnauthorizedError(
|
513
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
505
514
|
if _response.status_code == 403:
|
506
|
-
raise ForbiddenError(
|
515
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
507
516
|
if _response.status_code == 404:
|
508
|
-
raise NotFoundError(
|
517
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
509
518
|
if _response.status_code == 422:
|
510
|
-
raise UnprocessableEntityError(
|
519
|
+
raise UnprocessableEntityError(
|
520
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
521
|
+
)
|
511
522
|
if _response.status_code == 500:
|
512
|
-
raise InternalServerError(
|
523
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
513
524
|
try:
|
514
525
|
_response_json = _response.json()
|
515
526
|
except JSONDecodeError:
|
@@ -536,6 +547,8 @@ class AsyncBaseMixpeek:
|
|
536
547
|
|
537
548
|
- timeout: typing.Optional[float]. The timeout to be used, in seconds, for requests by default the timeout is 60 seconds, unless a custom httpx client is used, in which case a default is not set.
|
538
549
|
|
550
|
+
- follow_redirects: typing.Optional[bool]. Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
551
|
+
|
539
552
|
- httpx_client: typing.Optional[httpx.AsyncClient]. The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
540
553
|
---
|
541
554
|
from mixpeek.client import AsyncMixpeek
|
@@ -556,6 +569,7 @@ class AsyncBaseMixpeek:
|
|
556
569
|
index_id: typing.Optional[str] = None,
|
557
570
|
api_key: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv("MIXPEEK_API_KEY"),
|
558
571
|
timeout: typing.Optional[float] = None,
|
572
|
+
follow_redirects: typing.Optional[bool] = True,
|
559
573
|
httpx_client: typing.Optional[httpx.AsyncClient] = None,
|
560
574
|
):
|
561
575
|
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
|
@@ -568,7 +582,11 @@ class AsyncBaseMixpeek:
|
|
568
582
|
authorization=authorization,
|
569
583
|
index_id=index_id,
|
570
584
|
api_key=api_key,
|
571
|
-
httpx_client=
|
585
|
+
httpx_client=httpx_client
|
586
|
+
if httpx_client is not None
|
587
|
+
else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
588
|
+
if follow_redirects is not None
|
589
|
+
else httpx.AsyncClient(timeout=_defaulted_timeout),
|
572
590
|
timeout=_defaulted_timeout,
|
573
591
|
)
|
574
592
|
self.user = AsyncUserClient(client_wrapper=self._client_wrapper)
|
@@ -707,19 +725,21 @@ class AsyncBaseMixpeek:
|
|
707
725
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
708
726
|
)
|
709
727
|
if 200 <= _response.status_code < 300:
|
710
|
-
return
|
728
|
+
return pydantic_v1.parse_obj_as(ExtractResponse, _response.json()) # type: ignore
|
711
729
|
if _response.status_code == 400:
|
712
|
-
raise BadRequestError(
|
730
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
713
731
|
if _response.status_code == 401:
|
714
|
-
raise UnauthorizedError(
|
732
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
715
733
|
if _response.status_code == 403:
|
716
|
-
raise ForbiddenError(
|
734
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
717
735
|
if _response.status_code == 404:
|
718
|
-
raise NotFoundError(
|
736
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
719
737
|
if _response.status_code == 422:
|
720
|
-
raise UnprocessableEntityError(
|
738
|
+
raise UnprocessableEntityError(
|
739
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
740
|
+
)
|
721
741
|
if _response.status_code == 500:
|
722
|
-
raise InternalServerError(
|
742
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
723
743
|
try:
|
724
744
|
_response_json = _response.json()
|
725
745
|
except JSONDecodeError:
|
@@ -805,19 +825,21 @@ class AsyncBaseMixpeek:
|
|
805
825
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
806
826
|
)
|
807
827
|
if 200 <= _response.status_code < 300:
|
808
|
-
return
|
828
|
+
return pydantic_v1.parse_obj_as(GenerationResponse, _response.json()) # type: ignore
|
809
829
|
if _response.status_code == 400:
|
810
|
-
raise BadRequestError(
|
830
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
811
831
|
if _response.status_code == 401:
|
812
|
-
raise UnauthorizedError(
|
832
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
813
833
|
if _response.status_code == 403:
|
814
|
-
raise ForbiddenError(
|
834
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
815
835
|
if _response.status_code == 404:
|
816
|
-
raise NotFoundError(
|
836
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
817
837
|
if _response.status_code == 422:
|
818
|
-
raise UnprocessableEntityError(
|
838
|
+
raise UnprocessableEntityError(
|
839
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
840
|
+
)
|
819
841
|
if _response.status_code == 500:
|
820
|
-
raise InternalServerError(
|
842
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
821
843
|
try:
|
822
844
|
_response_json = _response.json()
|
823
845
|
except JSONDecodeError:
|
@@ -880,19 +902,21 @@ class AsyncBaseMixpeek:
|
|
880
902
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
881
903
|
)
|
882
904
|
if 200 <= _response.status_code < 300:
|
883
|
-
return
|
905
|
+
return pydantic_v1.parse_obj_as(ConfigsResponse, _response.json()) # type: ignore
|
884
906
|
if _response.status_code == 400:
|
885
|
-
raise BadRequestError(
|
907
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
886
908
|
if _response.status_code == 401:
|
887
|
-
raise UnauthorizedError(
|
909
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
888
910
|
if _response.status_code == 403:
|
889
|
-
raise ForbiddenError(
|
911
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
890
912
|
if _response.status_code == 404:
|
891
|
-
raise NotFoundError(
|
913
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
892
914
|
if _response.status_code == 422:
|
893
|
-
raise UnprocessableEntityError(
|
915
|
+
raise UnprocessableEntityError(
|
916
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
917
|
+
)
|
894
918
|
if _response.status_code == 500:
|
895
|
-
raise InternalServerError(
|
919
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
896
920
|
try:
|
897
921
|
_response_json = _response.json()
|
898
922
|
except JSONDecodeError:
|
@@ -960,19 +984,21 @@ class AsyncBaseMixpeek:
|
|
960
984
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
961
985
|
)
|
962
986
|
if 200 <= _response.status_code < 300:
|
963
|
-
return
|
987
|
+
return pydantic_v1.parse_obj_as(EmbeddingResponse, _response.json()) # type: ignore
|
964
988
|
if _response.status_code == 400:
|
965
|
-
raise BadRequestError(
|
989
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
966
990
|
if _response.status_code == 401:
|
967
|
-
raise UnauthorizedError(
|
991
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
968
992
|
if _response.status_code == 403:
|
969
|
-
raise ForbiddenError(
|
993
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
970
994
|
if _response.status_code == 404:
|
971
|
-
raise NotFoundError(
|
995
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
972
996
|
if _response.status_code == 422:
|
973
|
-
raise UnprocessableEntityError(
|
997
|
+
raise UnprocessableEntityError(
|
998
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
999
|
+
)
|
974
1000
|
if _response.status_code == 500:
|
975
|
-
raise InternalServerError(
|
1001
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
976
1002
|
try:
|
977
1003
|
_response_json = _response.json()
|
978
1004
|
except JSONDecodeError:
|
@@ -6,6 +6,7 @@ from .datetime_utils import serialize_datetime
|
|
6
6
|
from .file import File, convert_file_dict_to_httpx_tuples
|
7
7
|
from .http_client import AsyncHttpClient, HttpClient
|
8
8
|
from .jsonable_encoder import jsonable_encoder
|
9
|
+
from .pydantic_utilities import pydantic_v1
|
9
10
|
from .remove_none_from_dict import remove_none_from_dict
|
10
11
|
from .request_options import RequestOptions
|
11
12
|
|
@@ -20,6 +21,7 @@ __all__ = [
|
|
20
21
|
"SyncClientWrapper",
|
21
22
|
"convert_file_dict_to_httpx_tuples",
|
22
23
|
"jsonable_encoder",
|
24
|
+
"pydantic_v1",
|
23
25
|
"remove_none_from_dict",
|
24
26
|
"serialize_datetime",
|
25
27
|
]
|
@@ -27,7 +27,7 @@ class BaseClientWrapper:
|
|
27
27
|
headers: typing.Dict[str, str] = {
|
28
28
|
"X-Fern-Language": "Python",
|
29
29
|
"X-Fern-SDK-Name": "mixpeek",
|
30
|
-
"X-Fern-SDK-Version": "0.6.
|
30
|
+
"X-Fern-SDK-Version": "0.6.8",
|
31
31
|
}
|
32
32
|
if self._authorization is not None:
|
33
33
|
headers["Authorization"] = self._authorization
|
@@ -16,12 +16,8 @@ from pathlib import PurePath
|
|
16
16
|
from types import GeneratorType
|
17
17
|
from typing import Any, Callable, Dict, List, Optional, Set, Tuple, Union
|
18
18
|
|
19
|
-
try:
|
20
|
-
import pydantic.v1 as pydantic # type: ignore
|
21
|
-
except ImportError:
|
22
|
-
import pydantic # type: ignore
|
23
|
-
|
24
19
|
from .datetime_utils import serialize_datetime
|
20
|
+
from .pydantic_utilities import pydantic_v1
|
25
21
|
|
26
22
|
SetIntStr = Set[Union[int, str]]
|
27
23
|
DictIntStrAny = Dict[Union[int, str], Any]
|
@@ -36,7 +32,7 @@ def generate_encoders_by_class_tuples(
|
|
36
32
|
return encoders_by_class_tuples
|
37
33
|
|
38
34
|
|
39
|
-
encoders_by_class_tuples = generate_encoders_by_class_tuples(
|
35
|
+
encoders_by_class_tuples = generate_encoders_by_class_tuples(pydantic_v1.json.ENCODERS_BY_TYPE)
|
40
36
|
|
41
37
|
|
42
38
|
def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any], Any]]] = None) -> Any:
|
@@ -48,7 +44,7 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any]
|
|
48
44
|
for encoder_type, encoder_instance in custom_encoder.items():
|
49
45
|
if isinstance(obj, encoder_type):
|
50
46
|
return encoder_instance(obj)
|
51
|
-
if isinstance(obj,
|
47
|
+
if isinstance(obj, pydantic_v1.BaseModel):
|
52
48
|
encoder = getattr(obj.__config__, "json_encoders", {})
|
53
49
|
if custom_encoder:
|
54
50
|
encoder.update(custom_encoder)
|
@@ -84,8 +80,8 @@ def jsonable_encoder(obj: Any, custom_encoder: Optional[Dict[Any, Callable[[Any]
|
|
84
80
|
encoded_list.append(jsonable_encoder(item, custom_encoder=custom_encoder))
|
85
81
|
return encoded_list
|
86
82
|
|
87
|
-
if type(obj) in
|
88
|
-
return
|
83
|
+
if type(obj) in pydantic_v1.json.ENCODERS_BY_TYPE:
|
84
|
+
return pydantic_v1.json.ENCODERS_BY_TYPE[type(obj)](obj)
|
89
85
|
for encoder, classes_tuple in encoders_by_class_tuples.items():
|
90
86
|
if isinstance(obj, classes_tuple):
|
91
87
|
return encoder(obj)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import pydantic
|
4
|
+
|
5
|
+
IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.")
|
6
|
+
|
7
|
+
if IS_PYDANTIC_V2:
|
8
|
+
import pydantic.v1 as pydantic_v1 # type: ignore # nopycln: import
|
9
|
+
else:
|
10
|
+
import pydantic as pydantic_v1 # type: ignore # nopycln: import
|
11
|
+
|
12
|
+
__all__ = ["pydantic_v1"]
|
@@ -7,6 +7,7 @@ from json.decoder import JSONDecodeError
|
|
7
7
|
from ..core.api_error import ApiError
|
8
8
|
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
9
9
|
from ..core.jsonable_encoder import jsonable_encoder
|
10
|
+
from ..core.pydantic_utilities import pydantic_v1
|
10
11
|
from ..core.remove_none_from_dict import remove_none_from_dict
|
11
12
|
from ..core.request_options import RequestOptions
|
12
13
|
from ..errors.bad_request_error import BadRequestError
|
@@ -21,11 +22,6 @@ from ..types.pipeline_response import PipelineResponse
|
|
21
22
|
from ..types.pipeline_task_response import PipelineTaskResponse
|
22
23
|
from ..types.source_destination_mapping import SourceDestinationMapping
|
23
24
|
|
24
|
-
try:
|
25
|
-
import pydantic.v1 as pydantic # type: ignore
|
26
|
-
except ImportError:
|
27
|
-
import pydantic # type: ignore
|
28
|
-
|
29
25
|
# this is used as the default value for optional parameters
|
30
26
|
OMIT = typing.cast(typing.Any, ...)
|
31
27
|
|
@@ -80,19 +76,21 @@ class PipelineClient:
|
|
80
76
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
81
77
|
)
|
82
78
|
if 200 <= _response.status_code < 300:
|
83
|
-
return
|
79
|
+
return pydantic_v1.parse_obj_as(PipelineTaskResponse, _response.json()) # type: ignore
|
84
80
|
if _response.status_code == 400:
|
85
|
-
raise BadRequestError(
|
81
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
86
82
|
if _response.status_code == 401:
|
87
|
-
raise UnauthorizedError(
|
83
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
88
84
|
if _response.status_code == 403:
|
89
|
-
raise ForbiddenError(
|
85
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
90
86
|
if _response.status_code == 404:
|
91
|
-
raise NotFoundError(
|
87
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
92
88
|
if _response.status_code == 422:
|
93
|
-
raise UnprocessableEntityError(
|
89
|
+
raise UnprocessableEntityError(
|
90
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
91
|
+
)
|
94
92
|
if _response.status_code == 500:
|
95
|
-
raise InternalServerError(
|
93
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
96
94
|
try:
|
97
95
|
_response_json = _response.json()
|
98
96
|
except JSONDecodeError:
|
@@ -170,19 +168,21 @@ class PipelineClient:
|
|
170
168
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
171
169
|
)
|
172
170
|
if 200 <= _response.status_code < 300:
|
173
|
-
return
|
171
|
+
return pydantic_v1.parse_obj_as(PipelineResponse, _response.json()) # type: ignore
|
174
172
|
if _response.status_code == 400:
|
175
|
-
raise BadRequestError(
|
173
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
176
174
|
if _response.status_code == 401:
|
177
|
-
raise UnauthorizedError(
|
175
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
178
176
|
if _response.status_code == 403:
|
179
|
-
raise ForbiddenError(
|
177
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
180
178
|
if _response.status_code == 404:
|
181
|
-
raise NotFoundError(
|
179
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
182
180
|
if _response.status_code == 422:
|
183
|
-
raise UnprocessableEntityError(
|
181
|
+
raise UnprocessableEntityError(
|
182
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
183
|
+
)
|
184
184
|
if _response.status_code == 500:
|
185
|
-
raise InternalServerError(
|
185
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
186
186
|
try:
|
187
187
|
_response_json = _response.json()
|
188
188
|
except JSONDecodeError:
|
@@ -232,19 +232,21 @@ class PipelineClient:
|
|
232
232
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
233
233
|
)
|
234
234
|
if 200 <= _response.status_code < 300:
|
235
|
-
return
|
235
|
+
return pydantic_v1.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
236
236
|
if _response.status_code == 400:
|
237
|
-
raise BadRequestError(
|
237
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
238
238
|
if _response.status_code == 401:
|
239
|
-
raise UnauthorizedError(
|
239
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
240
240
|
if _response.status_code == 403:
|
241
|
-
raise ForbiddenError(
|
241
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
242
242
|
if _response.status_code == 404:
|
243
|
-
raise NotFoundError(
|
243
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
244
244
|
if _response.status_code == 422:
|
245
|
-
raise UnprocessableEntityError(
|
245
|
+
raise UnprocessableEntityError(
|
246
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
247
|
+
)
|
246
248
|
if _response.status_code == 500:
|
247
|
-
raise InternalServerError(
|
249
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
248
250
|
try:
|
249
251
|
_response_json = _response.json()
|
250
252
|
except JSONDecodeError:
|
@@ -302,19 +304,21 @@ class AsyncPipelineClient:
|
|
302
304
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
303
305
|
)
|
304
306
|
if 200 <= _response.status_code < 300:
|
305
|
-
return
|
307
|
+
return pydantic_v1.parse_obj_as(PipelineTaskResponse, _response.json()) # type: ignore
|
306
308
|
if _response.status_code == 400:
|
307
|
-
raise BadRequestError(
|
309
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
308
310
|
if _response.status_code == 401:
|
309
|
-
raise UnauthorizedError(
|
311
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
310
312
|
if _response.status_code == 403:
|
311
|
-
raise ForbiddenError(
|
313
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
312
314
|
if _response.status_code == 404:
|
313
|
-
raise NotFoundError(
|
315
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
314
316
|
if _response.status_code == 422:
|
315
|
-
raise UnprocessableEntityError(
|
317
|
+
raise UnprocessableEntityError(
|
318
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
319
|
+
)
|
316
320
|
if _response.status_code == 500:
|
317
|
-
raise InternalServerError(
|
321
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
318
322
|
try:
|
319
323
|
_response_json = _response.json()
|
320
324
|
except JSONDecodeError:
|
@@ -392,19 +396,21 @@ class AsyncPipelineClient:
|
|
392
396
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
393
397
|
)
|
394
398
|
if 200 <= _response.status_code < 300:
|
395
|
-
return
|
399
|
+
return pydantic_v1.parse_obj_as(PipelineResponse, _response.json()) # type: ignore
|
396
400
|
if _response.status_code == 400:
|
397
|
-
raise BadRequestError(
|
401
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
398
402
|
if _response.status_code == 401:
|
399
|
-
raise UnauthorizedError(
|
403
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
400
404
|
if _response.status_code == 403:
|
401
|
-
raise ForbiddenError(
|
405
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
402
406
|
if _response.status_code == 404:
|
403
|
-
raise NotFoundError(
|
407
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
404
408
|
if _response.status_code == 422:
|
405
|
-
raise UnprocessableEntityError(
|
409
|
+
raise UnprocessableEntityError(
|
410
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
411
|
+
)
|
406
412
|
if _response.status_code == 500:
|
407
|
-
raise InternalServerError(
|
413
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
408
414
|
try:
|
409
415
|
_response_json = _response.json()
|
410
416
|
except JSONDecodeError:
|
@@ -454,19 +460,21 @@ class AsyncPipelineClient:
|
|
454
460
|
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
455
461
|
)
|
456
462
|
if 200 <= _response.status_code < 300:
|
457
|
-
return
|
463
|
+
return pydantic_v1.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
458
464
|
if _response.status_code == 400:
|
459
|
-
raise BadRequestError(
|
465
|
+
raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
460
466
|
if _response.status_code == 401:
|
461
|
-
raise UnauthorizedError(
|
467
|
+
raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
462
468
|
if _response.status_code == 403:
|
463
|
-
raise ForbiddenError(
|
469
|
+
raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
464
470
|
if _response.status_code == 404:
|
465
|
-
raise NotFoundError(
|
471
|
+
raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
466
472
|
if _response.status_code == 422:
|
467
|
-
raise UnprocessableEntityError(
|
473
|
+
raise UnprocessableEntityError(
|
474
|
+
pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
|
475
|
+
)
|
468
476
|
if _response.status_code == 500:
|
469
|
-
raise InternalServerError(
|
477
|
+
raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
470
478
|
try:
|
471
479
|
_response_json = _response.json()
|
472
480
|
except JSONDecodeError:
|