mixpeek 0.2__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.
Files changed (74) hide show
  1. mixpeek/__init__.py +95 -71
  2. mixpeek/base_client.py +128 -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/errors/__init__.py +17 -0
  14. mixpeek/errors/bad_request_error.py +9 -0
  15. mixpeek/errors/forbidden_error.py +9 -0
  16. mixpeek/errors/internal_server_error.py +9 -0
  17. mixpeek/errors/not_found_error.py +9 -0
  18. mixpeek/errors/unauthorized_error.py +9 -0
  19. mixpeek/errors/unprocessable_entity_error.py +9 -0
  20. mixpeek/generators/__init__.py +2 -0
  21. mixpeek/generators/client.py +239 -0
  22. mixpeek/parse/__init__.py +2 -0
  23. mixpeek/parse/client.py +349 -0
  24. mixpeek/parse_client.py +14 -0
  25. mixpeek/pipelines/__init__.py +2 -0
  26. mixpeek/pipelines/client.py +546 -0
  27. mixpeek/py.typed +0 -0
  28. mixpeek/storage/__init__.py +2 -0
  29. mixpeek/storage/client.py +254 -0
  30. mixpeek/types/__init__.py +73 -0
  31. mixpeek/types/audio_params.py +29 -0
  32. mixpeek/types/configs_request.py +31 -0
  33. mixpeek/types/configs_response.py +31 -0
  34. mixpeek/types/connection.py +36 -0
  35. mixpeek/types/connection_engine.py +5 -0
  36. mixpeek/types/csv_params.py +29 -0
  37. mixpeek/types/destination_schema.py +31 -0
  38. mixpeek/types/embedding_request.py +32 -0
  39. mixpeek/types/embedding_response.py +30 -0
  40. mixpeek/types/error_message.py +29 -0
  41. mixpeek/types/error_response.py +30 -0
  42. mixpeek/types/field_schema.py +33 -0
  43. mixpeek/types/field_type.py +5 -0
  44. mixpeek/types/generation_response.py +34 -0
  45. mixpeek/types/html_params.py +29 -0
  46. mixpeek/types/http_validation_error.py +30 -0
  47. mixpeek/types/image_params.py +32 -0
  48. mixpeek/types/message.py +30 -0
  49. mixpeek/types/metadata.py +34 -0
  50. mixpeek/types/modality.py +5 -0
  51. mixpeek/types/model.py +30 -0
  52. mixpeek/types/pdf_params.py +41 -0
  53. mixpeek/types/pipeline_response.py +39 -0
  54. mixpeek/types/ppt_params.py +27 -0
  55. mixpeek/types/pptx_params.py +27 -0
  56. mixpeek/types/settings.py +35 -0
  57. mixpeek/types/source_schema.py +32 -0
  58. mixpeek/types/txt_params.py +27 -0
  59. mixpeek/types/validation_error.py +32 -0
  60. mixpeek/types/validation_error_loc_item.py +5 -0
  61. mixpeek/types/video_params.py +27 -0
  62. mixpeek/types/workflow_response.py +32 -0
  63. mixpeek/types/workflow_settings.py +30 -0
  64. mixpeek/types/xlsx_params.py +29 -0
  65. mixpeek/version.py +4 -0
  66. mixpeek/workflows/__init__.py +2 -0
  67. mixpeek/workflows/client.py +418 -0
  68. mixpeek-0.2.dist-info/LICENSE.rst → mixpeek-0.6.1.dist-info/LICENSE +10 -9
  69. mixpeek-0.6.1.dist-info/METADATA +145 -0
  70. mixpeek-0.6.1.dist-info/RECORD +71 -0
  71. {mixpeek-0.2.dist-info → mixpeek-0.6.1.dist-info}/WHEEL +1 -2
  72. mixpeek-0.2.dist-info/METADATA +0 -12
  73. mixpeek-0.2.dist-info/RECORD +0 -6
  74. mixpeek-0.2.dist-info/top_level.txt +0 -1
@@ -0,0 +1,349 @@
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.audio_params import AudioParams
19
+ from ..types.csv_params import CsvParams
20
+ from ..types.error_response import ErrorResponse
21
+ from ..types.html_params import HtmlParams
22
+ from ..types.http_validation_error import HttpValidationError
23
+ from ..types.image_params import ImageParams
24
+ from ..types.pdf_params import PdfParams
25
+ from ..types.ppt_params import PptParams
26
+ from ..types.pptx_params import PptxParams
27
+ from ..types.txt_params import TxtParams
28
+ from ..types.video_params import VideoParams
29
+ from ..types.xlsx_params import XlsxParams
30
+
31
+ try:
32
+ import pydantic.v1 as pydantic # type: ignore
33
+ except ImportError:
34
+ import pydantic # type: ignore
35
+
36
+ # this is used as the default value for optional parameters
37
+ OMIT = typing.cast(typing.Any, ...)
38
+
39
+
40
+ class ParseClient:
41
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
42
+ self._client_wrapper = client_wrapper
43
+
44
+ def parse_file(
45
+ self,
46
+ *,
47
+ file_url: typing.Optional[str] = OMIT,
48
+ contents: typing.Optional[str] = OMIT,
49
+ should_chunk: typing.Optional[bool] = OMIT,
50
+ clean_text: typing.Optional[bool] = OMIT,
51
+ max_characters_per_chunk: typing.Optional[int] = OMIT,
52
+ extract_tags: typing.Optional[bool] = OMIT,
53
+ summarize: typing.Optional[bool] = OMIT,
54
+ pdf_settings: typing.Optional[PdfParams] = OMIT,
55
+ html_settings: typing.Optional[HtmlParams] = OMIT,
56
+ csv_settings: typing.Optional[CsvParams] = OMIT,
57
+ ppt_settings: typing.Optional[PptParams] = OMIT,
58
+ pptx_settings: typing.Optional[PptxParams] = OMIT,
59
+ xlsx_settings: typing.Optional[XlsxParams] = OMIT,
60
+ txt_settings: typing.Optional[TxtParams] = OMIT,
61
+ audio_settings: typing.Optional[AudioParams] = OMIT,
62
+ image_settings: typing.Optional[ImageParams] = OMIT,
63
+ video_settings: typing.Optional[VideoParams] = OMIT,
64
+ request_options: typing.Optional[RequestOptions] = None,
65
+ ) -> typing.Any:
66
+ """
67
+ Parameters:
68
+ - file_url: typing.Optional[str].
69
+
70
+ - contents: typing.Optional[str].
71
+
72
+ - should_chunk: typing.Optional[bool].
73
+
74
+ - clean_text: typing.Optional[bool].
75
+
76
+ - max_characters_per_chunk: typing.Optional[int].
77
+
78
+ - extract_tags: typing.Optional[bool].
79
+
80
+ - summarize: typing.Optional[bool].
81
+
82
+ - pdf_settings: typing.Optional[PdfParams].
83
+
84
+ - html_settings: typing.Optional[HtmlParams].
85
+
86
+ - csv_settings: typing.Optional[CsvParams].
87
+
88
+ - ppt_settings: typing.Optional[PptParams].
89
+
90
+ - pptx_settings: typing.Optional[PptxParams].
91
+
92
+ - xlsx_settings: typing.Optional[XlsxParams].
93
+
94
+ - txt_settings: typing.Optional[TxtParams].
95
+
96
+ - audio_settings: typing.Optional[AudioParams].
97
+
98
+ - image_settings: typing.Optional[ImageParams].
99
+
100
+ - video_settings: typing.Optional[VideoParams].
101
+
102
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
103
+ ---
104
+ from mixpeek.client import Mixpeek
105
+
106
+ client = Mixpeek(
107
+ authorization="YOUR_AUTHORIZATION",
108
+ index_id="YOUR_INDEX_ID",
109
+ api_key="YOUR_API_KEY",
110
+ base_url="https://yourhost.com/path/to/api",
111
+ )
112
+ client.parse.parse_file()
113
+ """
114
+ _request: typing.Dict[str, typing.Any] = {}
115
+ if file_url is not OMIT:
116
+ _request["file_url"] = file_url
117
+ if contents is not OMIT:
118
+ _request["contents"] = contents
119
+ if should_chunk is not OMIT:
120
+ _request["should_chunk"] = should_chunk
121
+ if clean_text is not OMIT:
122
+ _request["clean_text"] = clean_text
123
+ if max_characters_per_chunk is not OMIT:
124
+ _request["max_characters_per_chunk"] = max_characters_per_chunk
125
+ if extract_tags is not OMIT:
126
+ _request["extract_tags"] = extract_tags
127
+ if summarize is not OMIT:
128
+ _request["summarize"] = summarize
129
+ if pdf_settings is not OMIT:
130
+ _request["pdf_settings"] = pdf_settings
131
+ if html_settings is not OMIT:
132
+ _request["html_settings"] = html_settings
133
+ if csv_settings is not OMIT:
134
+ _request["csv_settings"] = csv_settings
135
+ if ppt_settings is not OMIT:
136
+ _request["ppt_settings"] = ppt_settings
137
+ if pptx_settings is not OMIT:
138
+ _request["pptx_settings"] = pptx_settings
139
+ if xlsx_settings is not OMIT:
140
+ _request["xlsx_settings"] = xlsx_settings
141
+ if txt_settings is not OMIT:
142
+ _request["txt_settings"] = txt_settings
143
+ if audio_settings is not OMIT:
144
+ _request["audio_settings"] = audio_settings
145
+ if image_settings is not OMIT:
146
+ _request["image_settings"] = image_settings
147
+ if video_settings is not OMIT:
148
+ _request["video_settings"] = video_settings
149
+ _response = self._client_wrapper.httpx_client.request(
150
+ "POST",
151
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "parsers"),
152
+ params=jsonable_encoder(
153
+ request_options.get("additional_query_parameters") if request_options is not None else None
154
+ ),
155
+ json=jsonable_encoder(_request)
156
+ if request_options is None or request_options.get("additional_body_parameters") is None
157
+ else {
158
+ **jsonable_encoder(_request),
159
+ **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
160
+ },
161
+ headers=jsonable_encoder(
162
+ remove_none_from_dict(
163
+ {
164
+ **self._client_wrapper.get_headers(),
165
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
166
+ }
167
+ )
168
+ ),
169
+ timeout=request_options.get("timeout_in_seconds")
170
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
171
+ else self._client_wrapper.get_timeout(),
172
+ retries=0,
173
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
174
+ )
175
+ if 200 <= _response.status_code < 300:
176
+ return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
177
+ if _response.status_code == 400:
178
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
179
+ if _response.status_code == 401:
180
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
181
+ if _response.status_code == 403:
182
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
183
+ if _response.status_code == 404:
184
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
185
+ if _response.status_code == 422:
186
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
187
+ if _response.status_code == 500:
188
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
189
+ try:
190
+ _response_json = _response.json()
191
+ except JSONDecodeError:
192
+ raise ApiError(status_code=_response.status_code, body=_response.text)
193
+ raise ApiError(status_code=_response.status_code, body=_response_json)
194
+
195
+
196
+ class AsyncParseClient:
197
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
198
+ self._client_wrapper = client_wrapper
199
+
200
+ async def parse_file(
201
+ self,
202
+ *,
203
+ file_url: typing.Optional[str] = OMIT,
204
+ contents: typing.Optional[str] = OMIT,
205
+ should_chunk: typing.Optional[bool] = OMIT,
206
+ clean_text: typing.Optional[bool] = OMIT,
207
+ max_characters_per_chunk: typing.Optional[int] = OMIT,
208
+ extract_tags: typing.Optional[bool] = OMIT,
209
+ summarize: typing.Optional[bool] = OMIT,
210
+ pdf_settings: typing.Optional[PdfParams] = OMIT,
211
+ html_settings: typing.Optional[HtmlParams] = OMIT,
212
+ csv_settings: typing.Optional[CsvParams] = OMIT,
213
+ ppt_settings: typing.Optional[PptParams] = OMIT,
214
+ pptx_settings: typing.Optional[PptxParams] = OMIT,
215
+ xlsx_settings: typing.Optional[XlsxParams] = OMIT,
216
+ txt_settings: typing.Optional[TxtParams] = OMIT,
217
+ audio_settings: typing.Optional[AudioParams] = OMIT,
218
+ image_settings: typing.Optional[ImageParams] = OMIT,
219
+ video_settings: typing.Optional[VideoParams] = OMIT,
220
+ request_options: typing.Optional[RequestOptions] = None,
221
+ ) -> typing.Any:
222
+ """
223
+ Parameters:
224
+ - file_url: typing.Optional[str].
225
+
226
+ - contents: typing.Optional[str].
227
+
228
+ - should_chunk: typing.Optional[bool].
229
+
230
+ - clean_text: typing.Optional[bool].
231
+
232
+ - max_characters_per_chunk: typing.Optional[int].
233
+
234
+ - extract_tags: typing.Optional[bool].
235
+
236
+ - summarize: typing.Optional[bool].
237
+
238
+ - pdf_settings: typing.Optional[PdfParams].
239
+
240
+ - html_settings: typing.Optional[HtmlParams].
241
+
242
+ - csv_settings: typing.Optional[CsvParams].
243
+
244
+ - ppt_settings: typing.Optional[PptParams].
245
+
246
+ - pptx_settings: typing.Optional[PptxParams].
247
+
248
+ - xlsx_settings: typing.Optional[XlsxParams].
249
+
250
+ - txt_settings: typing.Optional[TxtParams].
251
+
252
+ - audio_settings: typing.Optional[AudioParams].
253
+
254
+ - image_settings: typing.Optional[ImageParams].
255
+
256
+ - video_settings: typing.Optional[VideoParams].
257
+
258
+ - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
259
+ ---
260
+ from mixpeek.client import AsyncMixpeek
261
+
262
+ client = AsyncMixpeek(
263
+ authorization="YOUR_AUTHORIZATION",
264
+ index_id="YOUR_INDEX_ID",
265
+ api_key="YOUR_API_KEY",
266
+ base_url="https://yourhost.com/path/to/api",
267
+ )
268
+ await client.parse.parse_file()
269
+ """
270
+ _request: typing.Dict[str, typing.Any] = {}
271
+ if file_url is not OMIT:
272
+ _request["file_url"] = file_url
273
+ if contents is not OMIT:
274
+ _request["contents"] = contents
275
+ if should_chunk is not OMIT:
276
+ _request["should_chunk"] = should_chunk
277
+ if clean_text is not OMIT:
278
+ _request["clean_text"] = clean_text
279
+ if max_characters_per_chunk is not OMIT:
280
+ _request["max_characters_per_chunk"] = max_characters_per_chunk
281
+ if extract_tags is not OMIT:
282
+ _request["extract_tags"] = extract_tags
283
+ if summarize is not OMIT:
284
+ _request["summarize"] = summarize
285
+ if pdf_settings is not OMIT:
286
+ _request["pdf_settings"] = pdf_settings
287
+ if html_settings is not OMIT:
288
+ _request["html_settings"] = html_settings
289
+ if csv_settings is not OMIT:
290
+ _request["csv_settings"] = csv_settings
291
+ if ppt_settings is not OMIT:
292
+ _request["ppt_settings"] = ppt_settings
293
+ if pptx_settings is not OMIT:
294
+ _request["pptx_settings"] = pptx_settings
295
+ if xlsx_settings is not OMIT:
296
+ _request["xlsx_settings"] = xlsx_settings
297
+ if txt_settings is not OMIT:
298
+ _request["txt_settings"] = txt_settings
299
+ if audio_settings is not OMIT:
300
+ _request["audio_settings"] = audio_settings
301
+ if image_settings is not OMIT:
302
+ _request["image_settings"] = image_settings
303
+ if video_settings is not OMIT:
304
+ _request["video_settings"] = video_settings
305
+ _response = await self._client_wrapper.httpx_client.request(
306
+ "POST",
307
+ urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "parsers"),
308
+ params=jsonable_encoder(
309
+ request_options.get("additional_query_parameters") if request_options is not None else None
310
+ ),
311
+ json=jsonable_encoder(_request)
312
+ if request_options is None or request_options.get("additional_body_parameters") is None
313
+ else {
314
+ **jsonable_encoder(_request),
315
+ **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
316
+ },
317
+ headers=jsonable_encoder(
318
+ remove_none_from_dict(
319
+ {
320
+ **self._client_wrapper.get_headers(),
321
+ **(request_options.get("additional_headers", {}) if request_options is not None else {}),
322
+ }
323
+ )
324
+ ),
325
+ timeout=request_options.get("timeout_in_seconds")
326
+ if request_options is not None and request_options.get("timeout_in_seconds") is not None
327
+ else self._client_wrapper.get_timeout(),
328
+ retries=0,
329
+ max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
330
+ )
331
+ if 200 <= _response.status_code < 300:
332
+ return pydantic.parse_obj_as(typing.Any, _response.json()) # type: ignore
333
+ if _response.status_code == 400:
334
+ raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
335
+ if _response.status_code == 401:
336
+ raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
337
+ if _response.status_code == 403:
338
+ raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
339
+ if _response.status_code == 404:
340
+ raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
341
+ if _response.status_code == 422:
342
+ raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
343
+ if _response.status_code == 500:
344
+ raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
345
+ try:
346
+ _response_json = _response.json()
347
+ except JSONDecodeError:
348
+ raise ApiError(status_code=_response.status_code, body=_response.text)
349
+ 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
+