mixpeek 0.1.0__py3-none-any.whl → 0.6.1__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.
- mixpeek/__init__.py +95 -71
- mixpeek/base_client.py +128 -0
- mixpeek/client.py +65 -0
- mixpeek/core/__init__.py +25 -0
- mixpeek/core/api_error.py +15 -0
- mixpeek/core/client_wrapper.py +83 -0
- mixpeek/core/datetime_utils.py +28 -0
- mixpeek/core/file.py +38 -0
- mixpeek/core/http_client.py +130 -0
- mixpeek/core/jsonable_encoder.py +103 -0
- mixpeek/core/remove_none_from_dict.py +11 -0
- mixpeek/core/request_options.py +32 -0
- mixpeek/errors/__init__.py +17 -0
- mixpeek/errors/bad_request_error.py +9 -0
- mixpeek/errors/forbidden_error.py +9 -0
- mixpeek/errors/internal_server_error.py +9 -0
- mixpeek/errors/not_found_error.py +9 -0
- mixpeek/errors/unauthorized_error.py +9 -0
- mixpeek/errors/unprocessable_entity_error.py +9 -0
- mixpeek/generators/__init__.py +2 -0
- mixpeek/generators/client.py +239 -0
- mixpeek/parse/__init__.py +2 -0
- mixpeek/parse/client.py +349 -0
- mixpeek/parse_client.py +14 -0
- mixpeek/pipelines/__init__.py +2 -0
- mixpeek/pipelines/client.py +546 -0
- mixpeek/py.typed +0 -0
- mixpeek/storage/__init__.py +2 -0
- mixpeek/storage/client.py +254 -0
- mixpeek/types/__init__.py +73 -0
- mixpeek/types/audio_params.py +29 -0
- mixpeek/types/configs_request.py +31 -0
- mixpeek/types/configs_response.py +31 -0
- mixpeek/types/connection.py +36 -0
- mixpeek/types/connection_engine.py +5 -0
- mixpeek/types/csv_params.py +29 -0
- mixpeek/types/destination_schema.py +31 -0
- mixpeek/types/embedding_request.py +32 -0
- mixpeek/types/embedding_response.py +30 -0
- mixpeek/types/error_message.py +29 -0
- mixpeek/types/error_response.py +30 -0
- mixpeek/types/field_schema.py +33 -0
- mixpeek/types/field_type.py +5 -0
- mixpeek/types/generation_response.py +34 -0
- mixpeek/types/html_params.py +29 -0
- mixpeek/types/http_validation_error.py +30 -0
- mixpeek/types/image_params.py +32 -0
- mixpeek/types/message.py +30 -0
- mixpeek/types/metadata.py +34 -0
- mixpeek/types/modality.py +5 -0
- mixpeek/types/model.py +30 -0
- mixpeek/types/pdf_params.py +41 -0
- mixpeek/types/pipeline_response.py +39 -0
- mixpeek/types/ppt_params.py +27 -0
- mixpeek/types/pptx_params.py +27 -0
- mixpeek/types/settings.py +35 -0
- mixpeek/types/source_schema.py +32 -0
- mixpeek/types/txt_params.py +27 -0
- mixpeek/types/validation_error.py +32 -0
- mixpeek/types/validation_error_loc_item.py +5 -0
- mixpeek/types/video_params.py +27 -0
- mixpeek/types/workflow_response.py +32 -0
- mixpeek/types/workflow_settings.py +30 -0
- mixpeek/types/xlsx_params.py +29 -0
- mixpeek/version.py +4 -0
- mixpeek/workflows/__init__.py +2 -0
- mixpeek/workflows/client.py +418 -0
- mixpeek-0.1.0.dist-info/LICENSE.rst → mixpeek-0.6.1.dist-info/LICENSE +10 -9
- mixpeek-0.6.1.dist-info/METADATA +145 -0
- mixpeek-0.6.1.dist-info/RECORD +71 -0
- {mixpeek-0.1.0.dist-info → mixpeek-0.6.1.dist-info}/WHEEL +1 -1
- mixpeek-0.1.0.dist-info/METADATA +0 -211
- mixpeek-0.1.0.dist-info/RECORD +0 -5
mixpeek/version.py
ADDED
@@ -0,0 +1,418 @@
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
2
|
+
|
3
|
+
import datetime as dt
|
4
|
+
import typing
|
5
|
+
import urllib.parse
|
6
|
+
from json.decoder import JSONDecodeError
|
7
|
+
|
8
|
+
from ..core.api_error import ApiError
|
9
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
10
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
11
|
+
from ..core.remove_none_from_dict import remove_none_from_dict
|
12
|
+
from ..core.request_options import RequestOptions
|
13
|
+
from ..errors.bad_request_error import BadRequestError
|
14
|
+
from ..errors.forbidden_error import ForbiddenError
|
15
|
+
from ..errors.internal_server_error import InternalServerError
|
16
|
+
from ..errors.not_found_error import NotFoundError
|
17
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
18
|
+
from ..errors.unprocessable_entity_error import UnprocessableEntityError
|
19
|
+
from ..types.error_response import ErrorResponse
|
20
|
+
from ..types.http_validation_error import HttpValidationError
|
21
|
+
from ..types.workflow_response import WorkflowResponse
|
22
|
+
from ..types.workflow_settings import WorkflowSettings
|
23
|
+
|
24
|
+
try:
|
25
|
+
import pydantic.v1 as pydantic # type: ignore
|
26
|
+
except ImportError:
|
27
|
+
import pydantic # type: ignore
|
28
|
+
|
29
|
+
# this is used as the default value for optional parameters
|
30
|
+
OMIT = typing.cast(typing.Any, ...)
|
31
|
+
|
32
|
+
|
33
|
+
class WorkflowsClient:
|
34
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
35
|
+
self._client_wrapper = client_wrapper
|
36
|
+
|
37
|
+
def create(
|
38
|
+
self,
|
39
|
+
*,
|
40
|
+
workflow_id: typing.Optional[str] = OMIT,
|
41
|
+
code_as_string: str,
|
42
|
+
metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
43
|
+
settings: WorkflowSettings,
|
44
|
+
workflow_name: typing.Optional[str] = OMIT,
|
45
|
+
last_run: typing.Optional[dt.datetime] = OMIT,
|
46
|
+
created_at: typing.Optional[dt.datetime] = OMIT,
|
47
|
+
request_options: typing.Optional[RequestOptions] = None,
|
48
|
+
) -> WorkflowResponse:
|
49
|
+
"""
|
50
|
+
Parameters:
|
51
|
+
- workflow_id: typing.Optional[str].
|
52
|
+
|
53
|
+
- code_as_string: str.
|
54
|
+
|
55
|
+
- metadata: typing.Optional[typing.Dict[str, typing.Any]].
|
56
|
+
|
57
|
+
- settings: WorkflowSettings.
|
58
|
+
|
59
|
+
- workflow_name: typing.Optional[str].
|
60
|
+
|
61
|
+
- last_run: typing.Optional[dt.datetime].
|
62
|
+
|
63
|
+
- created_at: typing.Optional[dt.datetime].
|
64
|
+
|
65
|
+
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
66
|
+
---
|
67
|
+
from mixpeek import WorkflowSettings
|
68
|
+
from mixpeek.client import Mixpeek
|
69
|
+
|
70
|
+
client = Mixpeek(
|
71
|
+
authorization="YOUR_AUTHORIZATION",
|
72
|
+
index_id="YOUR_INDEX_ID",
|
73
|
+
api_key="YOUR_API_KEY",
|
74
|
+
base_url="https://yourhost.com/path/to/api",
|
75
|
+
)
|
76
|
+
client.workflows.create(
|
77
|
+
code_as_string="code_as_string",
|
78
|
+
settings=WorkflowSettings(),
|
79
|
+
)
|
80
|
+
"""
|
81
|
+
_request: typing.Dict[str, typing.Any] = {"code_as_string": code_as_string, "settings": settings}
|
82
|
+
if workflow_id is not OMIT:
|
83
|
+
_request["workflow_id"] = workflow_id
|
84
|
+
if metadata is not OMIT:
|
85
|
+
_request["metadata"] = metadata
|
86
|
+
if workflow_name is not OMIT:
|
87
|
+
_request["workflow_name"] = workflow_name
|
88
|
+
if last_run is not OMIT:
|
89
|
+
_request["last_run"] = last_run
|
90
|
+
if created_at is not OMIT:
|
91
|
+
_request["created_at"] = created_at
|
92
|
+
_response = self._client_wrapper.httpx_client.request(
|
93
|
+
"POST",
|
94
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "workflows"),
|
95
|
+
params=jsonable_encoder(
|
96
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
97
|
+
),
|
98
|
+
json=jsonable_encoder(_request)
|
99
|
+
if request_options is None or request_options.get("additional_body_parameters") is None
|
100
|
+
else {
|
101
|
+
**jsonable_encoder(_request),
|
102
|
+
**(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
|
103
|
+
},
|
104
|
+
headers=jsonable_encoder(
|
105
|
+
remove_none_from_dict(
|
106
|
+
{
|
107
|
+
**self._client_wrapper.get_headers(),
|
108
|
+
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
109
|
+
}
|
110
|
+
)
|
111
|
+
),
|
112
|
+
timeout=request_options.get("timeout_in_seconds")
|
113
|
+
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
114
|
+
else self._client_wrapper.get_timeout(),
|
115
|
+
retries=0,
|
116
|
+
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
117
|
+
)
|
118
|
+
if 200 <= _response.status_code < 300:
|
119
|
+
return pydantic.parse_obj_as(WorkflowResponse, _response.json()) # type: ignore
|
120
|
+
if _response.status_code == 400:
|
121
|
+
raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
122
|
+
if _response.status_code == 401:
|
123
|
+
raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
124
|
+
if _response.status_code == 403:
|
125
|
+
raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
126
|
+
if _response.status_code == 404:
|
127
|
+
raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
128
|
+
if _response.status_code == 422:
|
129
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
130
|
+
if _response.status_code == 500:
|
131
|
+
raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
132
|
+
try:
|
133
|
+
_response_json = _response.json()
|
134
|
+
except JSONDecodeError:
|
135
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
136
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
137
|
+
|
138
|
+
def invoke(
|
139
|
+
self,
|
140
|
+
workflow_id: str,
|
141
|
+
*,
|
142
|
+
websocket_id: typing.Optional[str] = None,
|
143
|
+
request: typing.Dict[str, typing.Any],
|
144
|
+
request_options: typing.Optional[RequestOptions] = None,
|
145
|
+
) -> typing.Any:
|
146
|
+
"""
|
147
|
+
Parameters:
|
148
|
+
- workflow_id: str.
|
149
|
+
|
150
|
+
- websocket_id: typing.Optional[str].
|
151
|
+
|
152
|
+
- request: typing.Dict[str, typing.Any].
|
153
|
+
|
154
|
+
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
155
|
+
---
|
156
|
+
from mixpeek.client import Mixpeek
|
157
|
+
|
158
|
+
client = Mixpeek(
|
159
|
+
authorization="YOUR_AUTHORIZATION",
|
160
|
+
index_id="YOUR_INDEX_ID",
|
161
|
+
api_key="YOUR_API_KEY",
|
162
|
+
base_url="https://yourhost.com/path/to/api",
|
163
|
+
)
|
164
|
+
client.workflows.invoke(
|
165
|
+
workflow_id="workflow_id",
|
166
|
+
request={},
|
167
|
+
)
|
168
|
+
"""
|
169
|
+
_response = self._client_wrapper.httpx_client.request(
|
170
|
+
"POST",
|
171
|
+
urllib.parse.urljoin(
|
172
|
+
f"{self._client_wrapper.get_base_url()}/", f"workflows/{jsonable_encoder(workflow_id)}/invoke"
|
173
|
+
),
|
174
|
+
params=jsonable_encoder(
|
175
|
+
remove_none_from_dict(
|
176
|
+
{
|
177
|
+
"websocket_id": websocket_id,
|
178
|
+
**(
|
179
|
+
request_options.get("additional_query_parameters", {})
|
180
|
+
if request_options is not None
|
181
|
+
else {}
|
182
|
+
),
|
183
|
+
}
|
184
|
+
)
|
185
|
+
),
|
186
|
+
json=jsonable_encoder(request)
|
187
|
+
if request_options is None or request_options.get("additional_body_parameters") is None
|
188
|
+
else {
|
189
|
+
**jsonable_encoder(request),
|
190
|
+
**(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
|
191
|
+
},
|
192
|
+
headers=jsonable_encoder(
|
193
|
+
remove_none_from_dict(
|
194
|
+
{
|
195
|
+
**self._client_wrapper.get_headers(),
|
196
|
+
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
197
|
+
}
|
198
|
+
)
|
199
|
+
),
|
200
|
+
timeout=request_options.get("timeout_in_seconds")
|
201
|
+
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
202
|
+
else self._client_wrapper.get_timeout(),
|
203
|
+
retries=0,
|
204
|
+
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
205
|
+
)
|
206
|
+
if 200 <= _response.status_code < 300:
|
207
|
+
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
208
|
+
if _response.status_code == 400:
|
209
|
+
raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
210
|
+
if _response.status_code == 401:
|
211
|
+
raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
212
|
+
if _response.status_code == 403:
|
213
|
+
raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
214
|
+
if _response.status_code == 404:
|
215
|
+
raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
216
|
+
if _response.status_code == 422:
|
217
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
218
|
+
if _response.status_code == 500:
|
219
|
+
raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
220
|
+
try:
|
221
|
+
_response_json = _response.json()
|
222
|
+
except JSONDecodeError:
|
223
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
224
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
225
|
+
|
226
|
+
|
227
|
+
class AsyncWorkflowsClient:
|
228
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
229
|
+
self._client_wrapper = client_wrapper
|
230
|
+
|
231
|
+
async def create(
|
232
|
+
self,
|
233
|
+
*,
|
234
|
+
workflow_id: typing.Optional[str] = OMIT,
|
235
|
+
code_as_string: str,
|
236
|
+
metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
237
|
+
settings: WorkflowSettings,
|
238
|
+
workflow_name: typing.Optional[str] = OMIT,
|
239
|
+
last_run: typing.Optional[dt.datetime] = OMIT,
|
240
|
+
created_at: typing.Optional[dt.datetime] = OMIT,
|
241
|
+
request_options: typing.Optional[RequestOptions] = None,
|
242
|
+
) -> WorkflowResponse:
|
243
|
+
"""
|
244
|
+
Parameters:
|
245
|
+
- workflow_id: typing.Optional[str].
|
246
|
+
|
247
|
+
- code_as_string: str.
|
248
|
+
|
249
|
+
- metadata: typing.Optional[typing.Dict[str, typing.Any]].
|
250
|
+
|
251
|
+
- settings: WorkflowSettings.
|
252
|
+
|
253
|
+
- workflow_name: typing.Optional[str].
|
254
|
+
|
255
|
+
- last_run: typing.Optional[dt.datetime].
|
256
|
+
|
257
|
+
- created_at: typing.Optional[dt.datetime].
|
258
|
+
|
259
|
+
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
260
|
+
---
|
261
|
+
from mixpeek import WorkflowSettings
|
262
|
+
from mixpeek.client import AsyncMixpeek
|
263
|
+
|
264
|
+
client = AsyncMixpeek(
|
265
|
+
authorization="YOUR_AUTHORIZATION",
|
266
|
+
index_id="YOUR_INDEX_ID",
|
267
|
+
api_key="YOUR_API_KEY",
|
268
|
+
base_url="https://yourhost.com/path/to/api",
|
269
|
+
)
|
270
|
+
await client.workflows.create(
|
271
|
+
code_as_string="code_as_string",
|
272
|
+
settings=WorkflowSettings(),
|
273
|
+
)
|
274
|
+
"""
|
275
|
+
_request: typing.Dict[str, typing.Any] = {"code_as_string": code_as_string, "settings": settings}
|
276
|
+
if workflow_id is not OMIT:
|
277
|
+
_request["workflow_id"] = workflow_id
|
278
|
+
if metadata is not OMIT:
|
279
|
+
_request["metadata"] = metadata
|
280
|
+
if workflow_name is not OMIT:
|
281
|
+
_request["workflow_name"] = workflow_name
|
282
|
+
if last_run is not OMIT:
|
283
|
+
_request["last_run"] = last_run
|
284
|
+
if created_at is not OMIT:
|
285
|
+
_request["created_at"] = created_at
|
286
|
+
_response = await self._client_wrapper.httpx_client.request(
|
287
|
+
"POST",
|
288
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "workflows"),
|
289
|
+
params=jsonable_encoder(
|
290
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
291
|
+
),
|
292
|
+
json=jsonable_encoder(_request)
|
293
|
+
if request_options is None or request_options.get("additional_body_parameters") is None
|
294
|
+
else {
|
295
|
+
**jsonable_encoder(_request),
|
296
|
+
**(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
|
297
|
+
},
|
298
|
+
headers=jsonable_encoder(
|
299
|
+
remove_none_from_dict(
|
300
|
+
{
|
301
|
+
**self._client_wrapper.get_headers(),
|
302
|
+
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
303
|
+
}
|
304
|
+
)
|
305
|
+
),
|
306
|
+
timeout=request_options.get("timeout_in_seconds")
|
307
|
+
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
308
|
+
else self._client_wrapper.get_timeout(),
|
309
|
+
retries=0,
|
310
|
+
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
311
|
+
)
|
312
|
+
if 200 <= _response.status_code < 300:
|
313
|
+
return pydantic.parse_obj_as(WorkflowResponse, _response.json()) # type: ignore
|
314
|
+
if _response.status_code == 400:
|
315
|
+
raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
316
|
+
if _response.status_code == 401:
|
317
|
+
raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
318
|
+
if _response.status_code == 403:
|
319
|
+
raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
320
|
+
if _response.status_code == 404:
|
321
|
+
raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
322
|
+
if _response.status_code == 422:
|
323
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
324
|
+
if _response.status_code == 500:
|
325
|
+
raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
326
|
+
try:
|
327
|
+
_response_json = _response.json()
|
328
|
+
except JSONDecodeError:
|
329
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
330
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
331
|
+
|
332
|
+
async def invoke(
|
333
|
+
self,
|
334
|
+
workflow_id: str,
|
335
|
+
*,
|
336
|
+
websocket_id: typing.Optional[str] = None,
|
337
|
+
request: typing.Dict[str, typing.Any],
|
338
|
+
request_options: typing.Optional[RequestOptions] = None,
|
339
|
+
) -> typing.Any:
|
340
|
+
"""
|
341
|
+
Parameters:
|
342
|
+
- workflow_id: str.
|
343
|
+
|
344
|
+
- websocket_id: typing.Optional[str].
|
345
|
+
|
346
|
+
- request: typing.Dict[str, typing.Any].
|
347
|
+
|
348
|
+
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
349
|
+
---
|
350
|
+
from mixpeek.client import AsyncMixpeek
|
351
|
+
|
352
|
+
client = AsyncMixpeek(
|
353
|
+
authorization="YOUR_AUTHORIZATION",
|
354
|
+
index_id="YOUR_INDEX_ID",
|
355
|
+
api_key="YOUR_API_KEY",
|
356
|
+
base_url="https://yourhost.com/path/to/api",
|
357
|
+
)
|
358
|
+
await client.workflows.invoke(
|
359
|
+
workflow_id="workflow_id",
|
360
|
+
request={},
|
361
|
+
)
|
362
|
+
"""
|
363
|
+
_response = await self._client_wrapper.httpx_client.request(
|
364
|
+
"POST",
|
365
|
+
urllib.parse.urljoin(
|
366
|
+
f"{self._client_wrapper.get_base_url()}/", f"workflows/{jsonable_encoder(workflow_id)}/invoke"
|
367
|
+
),
|
368
|
+
params=jsonable_encoder(
|
369
|
+
remove_none_from_dict(
|
370
|
+
{
|
371
|
+
"websocket_id": websocket_id,
|
372
|
+
**(
|
373
|
+
request_options.get("additional_query_parameters", {})
|
374
|
+
if request_options is not None
|
375
|
+
else {}
|
376
|
+
),
|
377
|
+
}
|
378
|
+
)
|
379
|
+
),
|
380
|
+
json=jsonable_encoder(request)
|
381
|
+
if request_options is None or request_options.get("additional_body_parameters") is None
|
382
|
+
else {
|
383
|
+
**jsonable_encoder(request),
|
384
|
+
**(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
|
385
|
+
},
|
386
|
+
headers=jsonable_encoder(
|
387
|
+
remove_none_from_dict(
|
388
|
+
{
|
389
|
+
**self._client_wrapper.get_headers(),
|
390
|
+
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
391
|
+
}
|
392
|
+
)
|
393
|
+
),
|
394
|
+
timeout=request_options.get("timeout_in_seconds")
|
395
|
+
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
396
|
+
else self._client_wrapper.get_timeout(),
|
397
|
+
retries=0,
|
398
|
+
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
399
|
+
)
|
400
|
+
if 200 <= _response.status_code < 300:
|
401
|
+
return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
|
402
|
+
if _response.status_code == 400:
|
403
|
+
raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
404
|
+
if _response.status_code == 401:
|
405
|
+
raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
406
|
+
if _response.status_code == 403:
|
407
|
+
raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
408
|
+
if _response.status_code == 404:
|
409
|
+
raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
410
|
+
if _response.status_code == 422:
|
411
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
412
|
+
if _response.status_code == 500:
|
413
|
+
raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
414
|
+
try:
|
415
|
+
_response_json = _response.json()
|
416
|
+
except JSONDecodeError:
|
417
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
418
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Mixpeek.
|
3
4
|
|
4
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -11,10 +12,10 @@ furnished to do so, subject to the following conditions:
|
|
11
12
|
The above copyright notice and this permission notice shall be included in all
|
12
13
|
copies or substantial portions of the Software.
|
13
14
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,145 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: mixpeek
|
3
|
+
Version: 0.6.1
|
4
|
+
Summary:
|
5
|
+
Requires-Python: >=3.8,<4.0
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
7
|
+
Classifier: Programming Language :: Python :: 3.8
|
8
|
+
Classifier: Programming Language :: Python :: 3.9
|
9
|
+
Classifier: Programming Language :: Python :: 3.10
|
10
|
+
Classifier: Programming Language :: Python :: 3.11
|
11
|
+
Requires-Dist: httpx (>=0.21.2)
|
12
|
+
Requires-Dist: pydantic (>=1.9.2)
|
13
|
+
Requires-Dist: typing_extensions (>=4.0.0)
|
14
|
+
Description-Content-Type: text/markdown
|
15
|
+
|
16
|
+
# Mixpeek Python Library
|
17
|
+
|
18
|
+
[](https://github.com/fern-api/fern)
|
19
|
+
|
20
|
+
The Mixpeek Python Library provides convenient access to the Mixpeek API from applications written in Python.
|
21
|
+
|
22
|
+
## Installation
|
23
|
+
Add this dependency to your project's build file:
|
24
|
+
|
25
|
+
```bash
|
26
|
+
pip install mixpeek
|
27
|
+
# or
|
28
|
+
poetry add mixpeek
|
29
|
+
```
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
Simply import `Mixpeek` and start making calls to our API.
|
33
|
+
|
34
|
+
```python
|
35
|
+
from mixpeek.client import Mixpeek
|
36
|
+
|
37
|
+
client = Mixpeek(
|
38
|
+
api_key="..."
|
39
|
+
)
|
40
|
+
```
|
41
|
+
|
42
|
+
## Async Client
|
43
|
+
|
44
|
+
The SDK also exports an async client so that you can make non-blocking
|
45
|
+
calls to our API.
|
46
|
+
|
47
|
+
```python
|
48
|
+
from mixpeek.client import AsymcMixpeek
|
49
|
+
|
50
|
+
client = AsyncMixpeek(
|
51
|
+
api_key="..."
|
52
|
+
)
|
53
|
+
```
|
54
|
+
|
55
|
+
## Exception Handling
|
56
|
+
All errors thrown by the SDK will be subclasses of [`ApiError`](./src/mixpeek/core/api_error.py).
|
57
|
+
|
58
|
+
```python
|
59
|
+
import mixpeek
|
60
|
+
|
61
|
+
try:
|
62
|
+
client.search(...)
|
63
|
+
except mixpeek.core.ApiError as e: # Handle all errors
|
64
|
+
print(e.status_code)
|
65
|
+
print(e.body)
|
66
|
+
```
|
67
|
+
|
68
|
+
## Advanced
|
69
|
+
|
70
|
+
### Retries
|
71
|
+
The Mixpeek SDK is instrumented with automatic retries with exponential backoff. A request will be
|
72
|
+
retried as long as the request is deemed retriable and the number of retry attempts has not grown larger
|
73
|
+
than the configured retry limit.
|
74
|
+
|
75
|
+
A request is deemed retriable when any of the following HTTP status codes is returned:
|
76
|
+
|
77
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
78
|
+
- [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
|
79
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
80
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
|
81
|
+
|
82
|
+
Use the `max_retries` request option to configure this behavior.
|
83
|
+
|
84
|
+
```python
|
85
|
+
from mixpeek.client import Mixpeek
|
86
|
+
|
87
|
+
client = Mixpeek(...)
|
88
|
+
|
89
|
+
# Override retries for a specific method
|
90
|
+
client.search(..., {
|
91
|
+
max_retries=5
|
92
|
+
})
|
93
|
+
```
|
94
|
+
|
95
|
+
### Timeouts
|
96
|
+
By default, requests time out after 60 seconds. You can configure this with a
|
97
|
+
timeout option at the client or request level.
|
98
|
+
|
99
|
+
```python
|
100
|
+
from mixpeek.client import Mixpeek
|
101
|
+
|
102
|
+
client = Mixpeek(
|
103
|
+
# All timeouts are 20 seconds
|
104
|
+
timeout=20.0,
|
105
|
+
)
|
106
|
+
|
107
|
+
# Override timeout for a specific method
|
108
|
+
client.search(..., {
|
109
|
+
timeout_in_seconds=20.0
|
110
|
+
})
|
111
|
+
```
|
112
|
+
|
113
|
+
### Custom HTTP client
|
114
|
+
You can override the httpx client to customize it for your use-case. Some common use-cases
|
115
|
+
include support for proxies and transports.
|
116
|
+
|
117
|
+
```python
|
118
|
+
import httpx
|
119
|
+
|
120
|
+
from mixpeek.client import Mixpeek
|
121
|
+
|
122
|
+
client = Mixpeek(
|
123
|
+
http_client=httpx.Client(
|
124
|
+
proxies="http://my.test.proxy.example.com",
|
125
|
+
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
126
|
+
),
|
127
|
+
)
|
128
|
+
```
|
129
|
+
|
130
|
+
## Beta Status
|
131
|
+
|
132
|
+
This SDK is in beta, and there may be breaking changes between versions without a major
|
133
|
+
version update. Therefore, we recommend pinning the package version to a specific version.
|
134
|
+
This way, you can install the same version each time without breaking changes.
|
135
|
+
|
136
|
+
## Contributing
|
137
|
+
|
138
|
+
While we value open-source contributions to this SDK, this library is generated programmatically.
|
139
|
+
Additions made directly to this library would have to be moved over to our generation code,
|
140
|
+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
141
|
+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
142
|
+
an issue first to discuss with us!
|
143
|
+
|
144
|
+
On the other hand, contributions to the README are always very welcome!
|
145
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
mixpeek/__init__.py,sha256=4B8-4igYiq5ducl-dgigO8uB-vMRLdSsWKUhAvuVKCk,1924
|
2
|
+
mixpeek/base_client.py,sha256=eAzZwO69kWdkjhziRa7pwoGWEZXHYqd8C5X322fwi8s,5685
|
3
|
+
mixpeek/client.py,sha256=4FB09MxWYPm7ci7VBsuSYQvp-Fj6XWVaMmbcGg_J19o,2064
|
4
|
+
mixpeek/core/__init__.py,sha256=RWfyDqkzWsf8e3VGc3NV60MovfJbg5XWzNFGB2DZ0hA,790
|
5
|
+
mixpeek/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
|
6
|
+
mixpeek/core/client_wrapper.py,sha256=PGBWp928anR6i5sHHaPM0qBO2Y26iwq_r7k5i9d2Vz8,2622
|
7
|
+
mixpeek/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
|
8
|
+
mixpeek/core/file.py,sha256=sy1RUGZ3aJYuw998bZytxxo6QdgKmlnlgBaMvwEKCGg,1480
|
9
|
+
mixpeek/core/http_client.py,sha256=5ok6hqgZDJhg57EHvMnr0BBaHdG50QxFPKaCZ9aVWTc,5059
|
10
|
+
mixpeek/core/jsonable_encoder.py,sha256=IEhJedBpobt0zOfjW0pcH_sptQH3_frWtRF_s6i4HTM,3799
|
11
|
+
mixpeek/core/remove_none_from_dict.py,sha256=8m91FC3YuVem0Gm9_sXhJ2tGvP33owJJdrqCLEdowGw,330
|
12
|
+
mixpeek/core/request_options.py,sha256=-3QoOMMHI2exIyHH6Q2MD7rpo_6w-i6zMAy0nqWTN8c,1420
|
13
|
+
mixpeek/errors/__init__.py,sha256=whc3hN4Au19m_MxwQGjxUEfmSPyHqjmvOS0ESc0S7Qk,534
|
14
|
+
mixpeek/errors/bad_request_error.py,sha256=xHpPeLG8lM_kLR1QpOHI4xOuWVFEOgQfQi37kOcB0wc,285
|
15
|
+
mixpeek/errors/forbidden_error.py,sha256=CYoHSeucV5tjDJUTj19Dp6EoJZBvRswNAT9YhITApfE,284
|
16
|
+
mixpeek/errors/internal_server_error.py,sha256=fMmyOAEwUto7X9Mp65KbL0XkvepZsmT6p1p3hIBEuFg,289
|
17
|
+
mixpeek/errors/not_found_error.py,sha256=y5TwirUAu_TWO2d1Poh2ALf1IHj2v728z6AxrGexSVg,283
|
18
|
+
mixpeek/errors/unauthorized_error.py,sha256=nH-QOnS5KLta5PB4I-UoETY4i_Uz3-mF9xCwScE1JOE,287
|
19
|
+
mixpeek/errors/unprocessable_entity_error.py,sha256=FvR7XPlV3Xx5nu8HNlmLhBRdk4so_gCHjYT5PyZe6sM,313
|
20
|
+
mixpeek/generators/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
21
|
+
mixpeek/generators/client.py,sha256=vFcUs0dcOhEzsyqSjv3PFURLWcXnMevptjrSNTX_lao,10349
|
22
|
+
mixpeek/parse/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
23
|
+
mixpeek/parse/client.py,sha256=XZYxFa4c9q9z2MnI0HzJTo-aQpDXCv2q0gwOSPbV2PM,15236
|
24
|
+
mixpeek/parse_client.py,sha256=yRhssnPCsjSKnS0LknhiYicAOuRcRnRVcn7iWaswQBU,279
|
25
|
+
mixpeek/pipelines/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
26
|
+
mixpeek/pipelines/client.py,sha256=rMoFySQo_huL6ax9g0m-3biW3L7gGVbGuaRikw0w3Us,24847
|
27
|
+
mixpeek/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
28
|
+
mixpeek/storage/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
29
|
+
mixpeek/storage/client.py,sha256=dTlwRhsQT6Gc9bxdQEpxVe8mtvwgOegT5_ZSL9j3XW0,12837
|
30
|
+
mixpeek/types/__init__.py,sha256=-WczZgGItpn-rHVzJI5KiPPJzU7R8SN33QNNJG2MzqY,2150
|
31
|
+
mixpeek/types/audio_params.py,sha256=3KowuNn3ClYTXWsFvKHd8XrR1G8hmydusRzQQ6cAp5I,939
|
32
|
+
mixpeek/types/configs_request.py,sha256=tqF_xDoyBREiOw5snNxiF5bSy83nbthWqmhLWlKedTc,1011
|
33
|
+
mixpeek/types/configs_response.py,sha256=_gH6KyKLlC6CZcJeJYFO0ecr7QLSpmgKJqlqxiLcXCQ,959
|
34
|
+
mixpeek/types/connection.py,sha256=Zv8vsDnbfaGRMw8bRmyxT0hUYEtE2ZtIzbcS76uAuxM,1168
|
35
|
+
mixpeek/types/connection_engine.py,sha256=Gy43bjrZTkfiYtQQZGZFvJwHvHS0PxhZCf8l-LRrbRE,168
|
36
|
+
mixpeek/types/csv_params.py,sha256=Adc3qwAOGpvRRAu3iV6ObN5EbLPnzmsj8IxTyDc0ZCM,938
|
37
|
+
mixpeek/types/destination_schema.py,sha256=zZWqUs0EYOePXVtCfOzb1dyqBqQIgGkY6fa_Yzcy2ys,965
|
38
|
+
mixpeek/types/embedding_request.py,sha256=kmSrIu73ZryzXaCGeXP6qG99mJdVrBhThRpkxM8S0WA,1028
|
39
|
+
mixpeek/types/embedding_response.py,sha256=gQCNVHNVqYii4WLZisEbjkOllSaTwz3PxOhCBOe808Y,955
|
40
|
+
mixpeek/types/error_message.py,sha256=8Wh_GdH3jOviv_FYLyzQH20qbFTSzKqqjdZlOe2tlbE,905
|
41
|
+
mixpeek/types/error_response.py,sha256=SNectmi0OaoeWGAUvO7D0h40rf7jIEh3SLUtKxXs3ms,995
|
42
|
+
mixpeek/types/field_schema.py,sha256=tqx41gUDyiY7MLM9EFp03eD4xdrko2B9-s73zl36pXo,1075
|
43
|
+
mixpeek/types/field_type.py,sha256=bBXODNn4-VjjTt0U7AC9uj8XCDItYQmFQY9ZO76NmYY,153
|
44
|
+
mixpeek/types/generation_response.py,sha256=A07sNXlAY1sY3Cl7zajf4zZaZbdTPFpElg1oDf636P0,1117
|
45
|
+
mixpeek/types/html_params.py,sha256=5wylzm01kSNgIgMFMGmgj93LCJpubrX0gp2NuKxjVYE,949
|
46
|
+
mixpeek/types/http_validation_error.py,sha256=C6i5Fm74cECbzWUDvUDgAO9g9ryIFeKesoeqTUNakJc,1010
|
47
|
+
mixpeek/types/image_params.py,sha256=zdeXR_-EGw_7MKOF1D2zilRFiYJWohDnLVTo1VwLa7U,1070
|
48
|
+
mixpeek/types/message.py,sha256=21yebcf5X18U92khfedI-Gl02MkaBzDw4guLNy49bUk,918
|
49
|
+
mixpeek/types/metadata.py,sha256=YA7JZx_s7ChSqBA5Ay-zt8cGszDGmQv8PElYzi5N02E,1147
|
50
|
+
mixpeek/types/modality.py,sha256=GcEBlbYKdNs0qdyKnmrbgoDHyC1WYimv5PFKUjuI2jc,170
|
51
|
+
mixpeek/types/model.py,sha256=fau5pH8zO-hGbJzWwREO668gjedgrELmknKyOG9ELf4,918
|
52
|
+
mixpeek/types/pdf_params.py,sha256=9RF3S2uuE4oyaoPlRfI52phqWyD8ViOz6tl25HXBlek,1646
|
53
|
+
mixpeek/types/pipeline_response.py,sha256=YiouqRl8QpsVGK-8pbW5_LAZGKwihCrdfO5K6wqTtQo,1292
|
54
|
+
mixpeek/types/ppt_params.py,sha256=FS9BjjiZStDhGtaImv8uz9lhQG6r6a9gBiUJsPzhca0,888
|
55
|
+
mixpeek/types/pptx_params.py,sha256=W2hrSVvYjRxDrClFRoZKmM0dSb0YbCOjjT5dBiJMkZw,889
|
56
|
+
mixpeek/types/settings.py,sha256=F_KpO1F5_yHyRXQr7SPn7QIjVa05ViiyXShlB_ODKsI,1223
|
57
|
+
mixpeek/types/source_schema.py,sha256=8KStgcxPFv549adYMrZi2BMC7DvJDgL8yzjgFuMqnhE,1030
|
58
|
+
mixpeek/types/txt_params.py,sha256=nongbYA0BWr4kHvNBDdA6yoNkg6TXTsP2AG3tstyLd8,888
|
59
|
+
mixpeek/types/validation_error.py,sha256=dy6Ev1xmAsX_Wcck5AX8XvcVNP5xA-Lwlt7FTceiYqs,1029
|
60
|
+
mixpeek/types/validation_error_loc_item.py,sha256=LAtjCHIllWRBFXvAZ5QZpp7CPXjdtN9EB7HrLVo6EP0,128
|
61
|
+
mixpeek/types/video_params.py,sha256=SJlONUkncIVzFz37Q8iNNznYd10hdLgrMnRmxT5yz5E,890
|
62
|
+
mixpeek/types/workflow_response.py,sha256=t3fhcd780TUiCbFmX-2hRQY9oajjdE6g8AOy-lVS95A,1059
|
63
|
+
mixpeek/types/workflow_settings.py,sha256=1YXWRIJUxra85keIOglvJra62rItRyuH8PYcG3pgRvE,1003
|
64
|
+
mixpeek/types/xlsx_params.py,sha256=SXGQe3KhevNEdxjqIxxHmmuBrrk4IBetEcFaHq-_zQA,939
|
65
|
+
mixpeek/version.py,sha256=DfAuS0W7koTv3v8TZFxY1W5LvfaqOvG96P6Kc5fNnU0,75
|
66
|
+
mixpeek/workflows/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
|
67
|
+
mixpeek/workflows/client.py,sha256=tpIC84DYkn2HIFMkf1MDkizRPLRwsh9WQneZLopGDfc,18596
|
68
|
+
mixpeek-0.6.1.dist-info/LICENSE,sha256=4Wv5VxfDWkCcIouCfq1NrLwPm24Z83PE8Nbi3KyoEeg,1064
|
69
|
+
mixpeek-0.6.1.dist-info/METADATA,sha256=_X_-5UFQTLIrWWRn7vWjisd4UcoamF-JhXdIeVnMJ8Y,3985
|
70
|
+
mixpeek-0.6.1.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
71
|
+
mixpeek-0.6.1.dist-info/RECORD,,
|