mixpeek 0.2__py3-none-any.whl → 0.6.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. mixpeek/__init__.py +100 -71
  2. mixpeek/base_client.py +155 -0
  3. mixpeek/client.py +65 -0
  4. mixpeek/core/__init__.py +25 -0
  5. mixpeek/core/api_error.py +15 -0
  6. mixpeek/core/client_wrapper.py +83 -0
  7. mixpeek/core/datetime_utils.py +28 -0
  8. mixpeek/core/file.py +38 -0
  9. mixpeek/core/http_client.py +130 -0
  10. mixpeek/core/jsonable_encoder.py +103 -0
  11. mixpeek/core/remove_none_from_dict.py +11 -0
  12. mixpeek/core/request_options.py +32 -0
  13. mixpeek/embed/__init__.py +2 -0
  14. mixpeek/embed/client.py +350 -0
  15. mixpeek/environment.py +7 -0
  16. mixpeek/errors/__init__.py +17 -0
  17. mixpeek/errors/bad_request_error.py +9 -0
  18. mixpeek/errors/forbidden_error.py +9 -0
  19. mixpeek/errors/internal_server_error.py +9 -0
  20. mixpeek/errors/not_found_error.py +9 -0
  21. mixpeek/errors/unauthorized_error.py +9 -0
  22. mixpeek/errors/unprocessable_entity_error.py +9 -0
  23. mixpeek/extract/__init__.py +2 -0
  24. mixpeek/extract/client.py +347 -0
  25. mixpeek/generators/__init__.py +2 -0
  26. mixpeek/generators/client.py +237 -0
  27. mixpeek/parse/__init__.py +2 -0
  28. mixpeek/parse/client.py +111 -0
  29. mixpeek/parse_client.py +14 -0
  30. mixpeek/pipelines/__init__.py +2 -0
  31. mixpeek/pipelines/client.py +468 -0
  32. mixpeek/py.typed +0 -0
  33. mixpeek/storage/__init__.py +2 -0
  34. mixpeek/storage/client.py +250 -0
  35. mixpeek/types/__init__.py +73 -0
  36. mixpeek/types/api_key.py +31 -0
  37. mixpeek/types/audio_params.py +29 -0
  38. mixpeek/types/configs_response.py +31 -0
  39. mixpeek/types/connection.py +36 -0
  40. mixpeek/types/connection_engine.py +5 -0
  41. mixpeek/types/csv_params.py +29 -0
  42. mixpeek/types/destination.py +31 -0
  43. mixpeek/types/embedding_response.py +30 -0
  44. mixpeek/types/error_message.py +29 -0
  45. mixpeek/types/error_response.py +30 -0
  46. mixpeek/types/field_type.py +5 -0
  47. mixpeek/types/generation_response.py +34 -0
  48. mixpeek/types/html_params.py +29 -0
  49. mixpeek/types/http_validation_error.py +30 -0
  50. mixpeek/types/image_params.py +32 -0
  51. mixpeek/types/message.py +30 -0
  52. mixpeek/types/metadata.py +34 -0
  53. mixpeek/types/modality.py +5 -0
  54. mixpeek/types/model.py +31 -0
  55. mixpeek/types/models.py +5 -0
  56. mixpeek/types/pdf_params.py +41 -0
  57. mixpeek/types/ppt_params.py +27 -0
  58. mixpeek/types/pptx_params.py +27 -0
  59. mixpeek/types/settings.py +35 -0
  60. mixpeek/types/source.py +32 -0
  61. mixpeek/types/source_destination_mapping.py +33 -0
  62. mixpeek/types/txt_params.py +27 -0
  63. mixpeek/types/user.py +36 -0
  64. mixpeek/types/validation_error.py +32 -0
  65. mixpeek/types/validation_error_loc_item.py +5 -0
  66. mixpeek/types/video_params.py +27 -0
  67. mixpeek/types/workflow_response.py +32 -0
  68. mixpeek/types/workflow_settings.py +30 -0
  69. mixpeek/types/xlsx_params.py +29 -0
  70. mixpeek/users/__init__.py +2 -0
  71. mixpeek/users/client.py +308 -0
  72. mixpeek/version.py +4 -0
  73. mixpeek/workflows/__init__.py +2 -0
  74. mixpeek/workflows/client.py +536 -0
  75. mixpeek-0.2.dist-info/LICENSE.rst → mixpeek-0.6.2.dist-info/LICENSE +10 -9
  76. mixpeek-0.6.2.dist-info/METADATA +145 -0
  77. mixpeek-0.6.2.dist-info/RECORD +78 -0
  78. {mixpeek-0.2.dist-info → mixpeek-0.6.2.dist-info}/WHEEL +1 -2
  79. mixpeek-0.2.dist-info/METADATA +0 -12
  80. mixpeek-0.2.dist-info/RECORD +0 -6
  81. mixpeek-0.2.dist-info/top_level.txt +0 -1
@@ -0,0 +1,111 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ import urllib.parse
5
+ from json.decoder import JSONDecodeError
6
+
7
+ from ..core.api_error import ApiError
8
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from ..core.jsonable_encoder import jsonable_encoder
10
+ from ..core.remove_none_from_dict import remove_none_from_dict
11
+ from ..core.request_options import RequestOptions
12
+
13
+
14
+ class ParseClient:
15
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
16
+ self._client_wrapper = client_wrapper
17
+
18
+ def parse_file(self, *, request_options: typing.Optional[RequestOptions] = None) -> None:
19
+ """
20
+ Parameters:
21
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
22
+ ---
23
+ from mixpeek.client import Mixpeek
24
+
25
+ client = Mixpeek(
26
+ authorization="YOUR_AUTHORIZATION",
27
+ index_id="YOUR_INDEX_ID",
28
+ api_key="YOUR_API_KEY",
29
+ )
30
+ client.parse.parse_file()
31
+ """
32
+ _response = self._client_wrapper.httpx_client.request(
33
+ "POST",
34
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "parsers"),
35
+ params=jsonable_encoder(
36
+ request_options.get("additional_query_parameters") if request_options is not None else None
37
+ ),
38
+ json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
39
+ if request_options is not None
40
+ else None,
41
+ headers=jsonable_encoder(
42
+ remove_none_from_dict(
43
+ {
44
+ **self._client_wrapper.get_headers(),
45
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
46
+ }
47
+ )
48
+ ),
49
+ timeout=request_options.get("timeout_in_seconds")
50
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
51
+ else self._client_wrapper.get_timeout(),
52
+ retries=0,
53
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
54
+ )
55
+ if 200 <= _response.status_code < 300:
56
+ return
57
+ try:
58
+ _response_json = _response.json()
59
+ except JSONDecodeError:
60
+ raise ApiError(status_code=_response.status_code, body=_response.text)
61
+ raise ApiError(status_code=_response.status_code, body=_response_json)
62
+
63
+
64
+ class AsyncParseClient:
65
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
66
+ self._client_wrapper = client_wrapper
67
+
68
+ async def parse_file(self, *, request_options: typing.Optional[RequestOptions] = None) -> None:
69
+ """
70
+ Parameters:
71
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
72
+ ---
73
+ from mixpeek.client import AsyncMixpeek
74
+
75
+ client = AsyncMixpeek(
76
+ authorization="YOUR_AUTHORIZATION",
77
+ index_id="YOUR_INDEX_ID",
78
+ api_key="YOUR_API_KEY",
79
+ )
80
+ await client.parse.parse_file()
81
+ """
82
+ _response = await self._client_wrapper.httpx_client.request(
83
+ "POST",
84
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "parsers"),
85
+ params=jsonable_encoder(
86
+ request_options.get("additional_query_parameters") if request_options is not None else None
87
+ ),
88
+ json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
89
+ if request_options is not None
90
+ else None,
91
+ headers=jsonable_encoder(
92
+ remove_none_from_dict(
93
+ {
94
+ **self._client_wrapper.get_headers(),
95
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
96
+ }
97
+ )
98
+ ),
99
+ timeout=request_options.get("timeout_in_seconds")
100
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
101
+ else self._client_wrapper.get_timeout(),
102
+ retries=0,
103
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
104
+ )
105
+ if 200 <= _response.status_code < 300:
106
+ return
107
+ try:
108
+ _response_json = _response.json()
109
+ except JSONDecodeError:
110
+ raise ApiError(status_code=_response.status_code, body=_response.text)
111
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -0,0 +1,14 @@
1
+ from .parse.client import ParseClient, \
2
+ AsyncParseClient
3
+
4
+
5
+ class MixpeekParseClient(ParseClient):
6
+
7
+ def text(self, image_filepath: str) -> None:
8
+ pass
9
+
10
+
11
+ class AsyncMixpeekParseClient(AsyncParseClient):
12
+
13
+ def text(self, image_filepath: str) -> None:
14
+ pass
@@ -0,0 +1,2 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
@@ -0,0 +1,468 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ import urllib.parse
5
+ from json.decoder import JSONDecodeError
6
+
7
+ from ..core.api_error import ApiError
8
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from ..core.jsonable_encoder import jsonable_encoder
10
+ from ..core.remove_none_from_dict import remove_none_from_dict
11
+ from ..core.request_options import RequestOptions
12
+ from ..errors.bad_request_error import BadRequestError
13
+ from ..errors.forbidden_error import ForbiddenError
14
+ from ..errors.internal_server_error import InternalServerError
15
+ from ..errors.not_found_error import NotFoundError
16
+ from ..errors.unauthorized_error import UnauthorizedError
17
+ from ..errors.unprocessable_entity_error import UnprocessableEntityError
18
+ from ..types.error_response import ErrorResponse
19
+ from ..types.http_validation_error import HttpValidationError
20
+ from ..types.source_destination_mapping import SourceDestinationMapping
21
+
22
+ try:
23
+ import pydantic.v1 as pydantic # type: ignore
24
+ except ImportError:
25
+ import pydantic # type: ignore
26
+
27
+ # this is used as the default value for optional parameters
28
+ OMIT = typing.cast(typing.Any, ...)
29
+
30
+
31
+ class PipelinesClient:
32
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
33
+ self._client_wrapper = client_wrapper
34
+
35
+ def invoke(self, pipeline_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
36
+ """
37
+ Parameters:
38
+ - pipeline_id: str.
39
+
40
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
41
+ ---
42
+ from mixpeek.client import Mixpeek
43
+
44
+ client = Mixpeek(
45
+ authorization="YOUR_AUTHORIZATION",
46
+ index_id="YOUR_INDEX_ID",
47
+ api_key="YOUR_API_KEY",
48
+ )
49
+ client.pipelines.invoke(
50
+ pipeline_id="pipeline_id",
51
+ )
52
+ """
53
+ _response = self._client_wrapper.httpx_client.request(
54
+ "POST",
55
+ urllib.parse.urljoin(
56
+ f"{self._client_wrapper.get_base_url()}/", f"pipelines/{jsonable_encoder(pipeline_id)}"
57
+ ),
58
+ params=jsonable_encoder(
59
+ request_options.get("additional_query_parameters") if request_options is not None else None
60
+ ),
61
+ json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
62
+ if request_options is not None
63
+ else None,
64
+ headers=jsonable_encoder(
65
+ remove_none_from_dict(
66
+ {
67
+ **self._client_wrapper.get_headers(),
68
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
69
+ }
70
+ )
71
+ ),
72
+ timeout=request_options.get("timeout_in_seconds")
73
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
74
+ else self._client_wrapper.get_timeout(),
75
+ retries=0,
76
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
77
+ )
78
+ if 200 <= _response.status_code < 300:
79
+ return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
80
+ if _response.status_code == 400:
81
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
82
+ if _response.status_code == 401:
83
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
84
+ if _response.status_code == 403:
85
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
86
+ if _response.status_code == 404:
87
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
88
+ if _response.status_code == 422:
89
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
90
+ if _response.status_code == 500:
91
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
92
+ try:
93
+ _response_json = _response.json()
94
+ except JSONDecodeError:
95
+ raise ApiError(status_code=_response.status_code, body=_response.text)
96
+ raise ApiError(status_code=_response.status_code, body=_response_json)
97
+
98
+ def create(
99
+ self,
100
+ *,
101
+ source_destination_mappings: typing.Sequence[SourceDestinationMapping],
102
+ metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
103
+ request_options: typing.Optional[RequestOptions] = None,
104
+ ) -> typing.Any:
105
+ """
106
+ Parameters:
107
+ - source_destination_mappings: typing.Sequence[SourceDestinationMapping].
108
+
109
+ - metadata: typing.Optional[typing.Dict[str, typing.Any]].
110
+
111
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
112
+ ---
113
+ from mixpeek import Destination, Source, SourceDestinationMapping
114
+ from mixpeek.client import Mixpeek
115
+
116
+ client = Mixpeek(
117
+ authorization="YOUR_AUTHORIZATION",
118
+ index_id="YOUR_INDEX_ID",
119
+ api_key="YOUR_API_KEY",
120
+ )
121
+ client.pipelines.create(
122
+ source_destination_mappings=[
123
+ SourceDestinationMapping(
124
+ embedding_model="embedding_model",
125
+ source=Source(
126
+ field="field",
127
+ type="file_url",
128
+ settings={},
129
+ ),
130
+ destination=Destination(
131
+ collection="collection",
132
+ field="field",
133
+ embedding="embedding",
134
+ ),
135
+ )
136
+ ],
137
+ )
138
+ """
139
+ _request: typing.Dict[str, typing.Any] = {"source_destination_mappings": source_destination_mappings}
140
+ if metadata is not OMIT:
141
+ _request["metadata"] = metadata
142
+ _response = self._client_wrapper.httpx_client.request(
143
+ "POST",
144
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "pipelines"),
145
+ params=jsonable_encoder(
146
+ request_options.get("additional_query_parameters") if request_options is not None else None
147
+ ),
148
+ json=jsonable_encoder(_request)
149
+ if request_options is None or request_options.get("additional_body_parameters") is None
150
+ else {
151
+ **jsonable_encoder(_request),
152
+ **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
153
+ },
154
+ headers=jsonable_encoder(
155
+ remove_none_from_dict(
156
+ {
157
+ **self._client_wrapper.get_headers(),
158
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
159
+ }
160
+ )
161
+ ),
162
+ timeout=request_options.get("timeout_in_seconds")
163
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
164
+ else self._client_wrapper.get_timeout(),
165
+ retries=0,
166
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
167
+ )
168
+ if 200 <= _response.status_code < 300:
169
+ return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
170
+ if _response.status_code == 400:
171
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
172
+ if _response.status_code == 401:
173
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
174
+ if _response.status_code == 403:
175
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
176
+ if _response.status_code == 404:
177
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
178
+ if _response.status_code == 422:
179
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
180
+ if _response.status_code == 500:
181
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
182
+ try:
183
+ _response_json = _response.json()
184
+ except JSONDecodeError:
185
+ raise ApiError(status_code=_response.status_code, body=_response.text)
186
+ raise ApiError(status_code=_response.status_code, body=_response_json)
187
+
188
+ def get_status(self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
189
+ """
190
+ Query tasks status.
191
+
192
+ Parameters:
193
+ - task_id: str.
194
+
195
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
196
+ ---
197
+ from mixpeek.client import Mixpeek
198
+
199
+ client = Mixpeek(
200
+ authorization="YOUR_AUTHORIZATION",
201
+ index_id="YOUR_INDEX_ID",
202
+ api_key="YOUR_API_KEY",
203
+ )
204
+ client.pipelines.get_status(
205
+ task_id="task_id",
206
+ )
207
+ """
208
+ _response = self._client_wrapper.httpx_client.request(
209
+ "GET",
210
+ urllib.parse.urljoin(
211
+ f"{self._client_wrapper.get_base_url()}/", f"pipelines/status/{jsonable_encoder(task_id)}"
212
+ ),
213
+ params=jsonable_encoder(
214
+ request_options.get("additional_query_parameters") if request_options is not None else None
215
+ ),
216
+ headers=jsonable_encoder(
217
+ remove_none_from_dict(
218
+ {
219
+ **self._client_wrapper.get_headers(),
220
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
221
+ }
222
+ )
223
+ ),
224
+ timeout=request_options.get("timeout_in_seconds")
225
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
226
+ else self._client_wrapper.get_timeout(),
227
+ retries=0,
228
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
229
+ )
230
+ if 200 <= _response.status_code < 300:
231
+ return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
232
+ if _response.status_code == 400:
233
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
234
+ if _response.status_code == 401:
235
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
236
+ if _response.status_code == 403:
237
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
238
+ if _response.status_code == 404:
239
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
240
+ if _response.status_code == 422:
241
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
242
+ if _response.status_code == 500:
243
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
244
+ try:
245
+ _response_json = _response.json()
246
+ except JSONDecodeError:
247
+ raise ApiError(status_code=_response.status_code, body=_response.text)
248
+ raise ApiError(status_code=_response.status_code, body=_response_json)
249
+
250
+
251
+ class AsyncPipelinesClient:
252
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
253
+ self._client_wrapper = client_wrapper
254
+
255
+ async def invoke(self, pipeline_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
256
+ """
257
+ Parameters:
258
+ - pipeline_id: str.
259
+
260
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
261
+ ---
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
+ )
269
+ await client.pipelines.invoke(
270
+ pipeline_id="pipeline_id",
271
+ )
272
+ """
273
+ _response = await self._client_wrapper.httpx_client.request(
274
+ "POST",
275
+ urllib.parse.urljoin(
276
+ f"{self._client_wrapper.get_base_url()}/", f"pipelines/{jsonable_encoder(pipeline_id)}"
277
+ ),
278
+ params=jsonable_encoder(
279
+ request_options.get("additional_query_parameters") if request_options is not None else None
280
+ ),
281
+ json=jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))
282
+ if request_options is not None
283
+ else None,
284
+ headers=jsonable_encoder(
285
+ remove_none_from_dict(
286
+ {
287
+ **self._client_wrapper.get_headers(),
288
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
289
+ }
290
+ )
291
+ ),
292
+ timeout=request_options.get("timeout_in_seconds")
293
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
294
+ else self._client_wrapper.get_timeout(),
295
+ retries=0,
296
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
297
+ )
298
+ if 200 <= _response.status_code < 300:
299
+ return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
300
+ if _response.status_code == 400:
301
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
302
+ if _response.status_code == 401:
303
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
304
+ if _response.status_code == 403:
305
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
306
+ if _response.status_code == 404:
307
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
308
+ if _response.status_code == 422:
309
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
310
+ if _response.status_code == 500:
311
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
312
+ try:
313
+ _response_json = _response.json()
314
+ except JSONDecodeError:
315
+ raise ApiError(status_code=_response.status_code, body=_response.text)
316
+ raise ApiError(status_code=_response.status_code, body=_response_json)
317
+
318
+ async def create(
319
+ self,
320
+ *,
321
+ source_destination_mappings: typing.Sequence[SourceDestinationMapping],
322
+ metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
323
+ request_options: typing.Optional[RequestOptions] = None,
324
+ ) -> typing.Any:
325
+ """
326
+ Parameters:
327
+ - source_destination_mappings: typing.Sequence[SourceDestinationMapping].
328
+
329
+ - metadata: typing.Optional[typing.Dict[str, typing.Any]].
330
+
331
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
332
+ ---
333
+ from mixpeek import Destination, Source, SourceDestinationMapping
334
+ from mixpeek.client import AsyncMixpeek
335
+
336
+ client = AsyncMixpeek(
337
+ authorization="YOUR_AUTHORIZATION",
338
+ index_id="YOUR_INDEX_ID",
339
+ api_key="YOUR_API_KEY",
340
+ )
341
+ await client.pipelines.create(
342
+ source_destination_mappings=[
343
+ SourceDestinationMapping(
344
+ embedding_model="embedding_model",
345
+ source=Source(
346
+ field="field",
347
+ type="file_url",
348
+ settings={},
349
+ ),
350
+ destination=Destination(
351
+ collection="collection",
352
+ field="field",
353
+ embedding="embedding",
354
+ ),
355
+ )
356
+ ],
357
+ )
358
+ """
359
+ _request: typing.Dict[str, typing.Any] = {"source_destination_mappings": source_destination_mappings}
360
+ if metadata is not OMIT:
361
+ _request["metadata"] = metadata
362
+ _response = await self._client_wrapper.httpx_client.request(
363
+ "POST",
364
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "pipelines"),
365
+ params=jsonable_encoder(
366
+ request_options.get("additional_query_parameters") if request_options is not None else None
367
+ ),
368
+ json=jsonable_encoder(_request)
369
+ if request_options is None or request_options.get("additional_body_parameters") is None
370
+ else {
371
+ **jsonable_encoder(_request),
372
+ **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
373
+ },
374
+ headers=jsonable_encoder(
375
+ remove_none_from_dict(
376
+ {
377
+ **self._client_wrapper.get_headers(),
378
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
379
+ }
380
+ )
381
+ ),
382
+ timeout=request_options.get("timeout_in_seconds")
383
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
384
+ else self._client_wrapper.get_timeout(),
385
+ retries=0,
386
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
387
+ )
388
+ if 200 <= _response.status_code < 300:
389
+ return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
390
+ if _response.status_code == 400:
391
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
392
+ if _response.status_code == 401:
393
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
394
+ if _response.status_code == 403:
395
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
396
+ if _response.status_code == 404:
397
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
398
+ if _response.status_code == 422:
399
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
400
+ if _response.status_code == 500:
401
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
402
+ try:
403
+ _response_json = _response.json()
404
+ except JSONDecodeError:
405
+ raise ApiError(status_code=_response.status_code, body=_response.text)
406
+ raise ApiError(status_code=_response.status_code, body=_response_json)
407
+
408
+ async def get_status(self, task_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> typing.Any:
409
+ """
410
+ Query tasks status.
411
+
412
+ Parameters:
413
+ - task_id: str.
414
+
415
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
416
+ ---
417
+ from mixpeek.client import AsyncMixpeek
418
+
419
+ client = AsyncMixpeek(
420
+ authorization="YOUR_AUTHORIZATION",
421
+ index_id="YOUR_INDEX_ID",
422
+ api_key="YOUR_API_KEY",
423
+ )
424
+ await client.pipelines.get_status(
425
+ task_id="task_id",
426
+ )
427
+ """
428
+ _response = await self._client_wrapper.httpx_client.request(
429
+ "GET",
430
+ urllib.parse.urljoin(
431
+ f"{self._client_wrapper.get_base_url()}/", f"pipelines/status/{jsonable_encoder(task_id)}"
432
+ ),
433
+ params=jsonable_encoder(
434
+ request_options.get("additional_query_parameters") if request_options is not None else None
435
+ ),
436
+ headers=jsonable_encoder(
437
+ remove_none_from_dict(
438
+ {
439
+ **self._client_wrapper.get_headers(),
440
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
441
+ }
442
+ )
443
+ ),
444
+ timeout=request_options.get("timeout_in_seconds")
445
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
446
+ else self._client_wrapper.get_timeout(),
447
+ retries=0,
448
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
449
+ )
450
+ if 200 <= _response.status_code < 300:
451
+ return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
452
+ if _response.status_code == 400:
453
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
454
+ if _response.status_code == 401:
455
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
456
+ if _response.status_code == 403:
457
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
458
+ if _response.status_code == 404:
459
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
460
+ if _response.status_code == 422:
461
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
462
+ if _response.status_code == 500:
463
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
464
+ try:
465
+ _response_json = _response.json()
466
+ except JSONDecodeError:
467
+ raise ApiError(status_code=_response.status_code, body=_response.text)
468
+ raise ApiError(status_code=_response.status_code, body=_response_json)
mixpeek/py.typed ADDED
File without changes
@@ -0,0 +1,2 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+