mixpeek 0.6.1__py3-none-any.whl → 0.6.5__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 (44) hide show
  1. mixpeek/__init__.py +24 -15
  2. mixpeek/base_client.py +883 -22
  3. mixpeek/client.py +7 -7
  4. mixpeek/core/client_wrapper.py +1 -1
  5. mixpeek/environment.py +7 -0
  6. mixpeek/{pipelines → pipeline}/client.py +60 -132
  7. mixpeek/storage/__init__.py +3 -0
  8. mixpeek/storage/client.py +7 -116
  9. mixpeek/storage/sample/client.py +282 -0
  10. mixpeek/types/__init__.py +18 -10
  11. mixpeek/types/{embedding_request.py → api_key.py} +4 -5
  12. mixpeek/types/configs_response.py +14 -3
  13. mixpeek/types/connection.py +1 -1
  14. mixpeek/types/{field_schema.py → destination.py} +15 -6
  15. mixpeek/types/embedding_response.py +6 -2
  16. mixpeek/types/extract_response.py +39 -0
  17. mixpeek/types/field_type.py +1 -1
  18. mixpeek/types/generation_response.py +6 -4
  19. mixpeek/types/message.py +9 -2
  20. mixpeek/types/metadata.py +0 -2
  21. mixpeek/types/modality.py +1 -1
  22. mixpeek/types/model.py +10 -2
  23. mixpeek/types/models.py +5 -0
  24. mixpeek/types/pipeline_response.py +19 -9
  25. mixpeek/types/{configs_request.py → pipeline_task_response.py} +5 -4
  26. mixpeek/types/source.py +43 -0
  27. mixpeek/types/source_destination_mapping.py +44 -0
  28. mixpeek/types/user.py +36 -0
  29. mixpeek/types/{destination_schema.py → workflow_code_response.py} +2 -4
  30. mixpeek/user/client.py +308 -0
  31. mixpeek/{workflows → workflow}/client.py +127 -10
  32. {mixpeek-0.6.1.dist-info → mixpeek-0.6.5.dist-info}/METADATA +1 -1
  33. mixpeek-0.6.5.dist-info/RECORD +75 -0
  34. mixpeek/generators/client.py +0 -239
  35. mixpeek/parse/client.py +0 -349
  36. mixpeek/parse_client.py +0 -14
  37. mixpeek/types/source_schema.py +0 -32
  38. mixpeek-0.6.1.dist-info/RECORD +0 -71
  39. /mixpeek/{generators → pipeline}/__init__.py +0 -0
  40. /mixpeek/{parse → storage/sample}/__init__.py +0 -0
  41. /mixpeek/{pipelines → user}/__init__.py +0 -0
  42. /mixpeek/{workflows → workflow}/__init__.py +0 -0
  43. {mixpeek-0.6.1.dist-info → mixpeek-0.6.5.dist-info}/LICENSE +0 -0
  44. {mixpeek-0.6.1.dist-info → mixpeek-0.6.5.dist-info}/WHEEL +0 -0
@@ -0,0 +1,75 @@
1
+ mixpeek/__init__.py,sha256=oC5q6VUOdDubpFT7PRtno7IUyzgiU9uSRyA7f0Ka0eY,2098
2
+ mixpeek/base_client.py,sha256=j5FwPDpVqWeSs4UAwn65DXIeaKrtkyCgK1BF9T6X8Nk,44940
3
+ mixpeek/client.py,sha256=ka2f4aHaZwGq5ju3MnDLImlgCjce3BXXl4gw5I9HB90,2047
4
+ mixpeek/core/__init__.py,sha256=RWfyDqkzWsf8e3VGc3NV60MovfJbg5XWzNFGB2DZ0hA,790
5
+ mixpeek/core/api_error.py,sha256=RE8LELok2QCjABadECTvtDp7qejA1VmINCh6TbqPwSE,426
6
+ mixpeek/core/client_wrapper.py,sha256=3m0ZPwQ3crCQGAMM2uU0ZIqJcyxyZoaeDr79TE8Pddc,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/environment.py,sha256=-muYBZQwCYNISO0ic3Kkn_hPqfrB_VpOv_RpBoCKA6Q,156
14
+ mixpeek/errors/__init__.py,sha256=whc3hN4Au19m_MxwQGjxUEfmSPyHqjmvOS0ESc0S7Qk,534
15
+ mixpeek/errors/bad_request_error.py,sha256=xHpPeLG8lM_kLR1QpOHI4xOuWVFEOgQfQi37kOcB0wc,285
16
+ mixpeek/errors/forbidden_error.py,sha256=CYoHSeucV5tjDJUTj19Dp6EoJZBvRswNAT9YhITApfE,284
17
+ mixpeek/errors/internal_server_error.py,sha256=fMmyOAEwUto7X9Mp65KbL0XkvepZsmT6p1p3hIBEuFg,289
18
+ mixpeek/errors/not_found_error.py,sha256=y5TwirUAu_TWO2d1Poh2ALf1IHj2v728z6AxrGexSVg,283
19
+ mixpeek/errors/unauthorized_error.py,sha256=nH-QOnS5KLta5PB4I-UoETY4i_Uz3-mF9xCwScE1JOE,287
20
+ mixpeek/errors/unprocessable_entity_error.py,sha256=FvR7XPlV3Xx5nu8HNlmLhBRdk4so_gCHjYT5PyZe6sM,313
21
+ mixpeek/pipeline/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
22
+ mixpeek/pipeline/client.py,sha256=l5bv4trvLOTFoMSWtghBBdfDRYxrfH4WgOpyvxTkajY,22611
23
+ mixpeek/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
24
+ mixpeek/storage/__init__.py,sha256=DXpRqQD-Sr8yiyNQYMJeAq10AQAXryiMx42UW4mDNrk,108
25
+ mixpeek/storage/client.py,sha256=RRxkwuvGr0ozvthNxoKCeMtW71LhdbRggKexHleSMq8,7103
26
+ mixpeek/storage/sample/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
27
+ mixpeek/storage/sample/client.py,sha256=tIjSkyqTnp4jLSd4w7qW_Kt7aoYEZeP33_9LR7BBz5Q,13404
28
+ mixpeek/types/__init__.py,sha256=ap7tSQXWWqyaWSO6dDuCOfsNUPFOj_DsqVaoZ32_Y7U,2371
29
+ mixpeek/types/api_key.py,sha256=DnZf9eer296hvfC5PK4Hcrg7-LywKA_fSn68aaMzf5U,1013
30
+ mixpeek/types/audio_params.py,sha256=3KowuNn3ClYTXWsFvKHd8XrR1G8hmydusRzQQ6cAp5I,939
31
+ mixpeek/types/configs_response.py,sha256=x58BeJQr36oQhA61TFw6kbX8B-endOzfrs2L14FDZ8M,1198
32
+ mixpeek/types/connection.py,sha256=b2dw5xagRgTuGjBB_NSW0JsVeSWGiFwkM6-E3jQc9IA,1144
33
+ mixpeek/types/connection_engine.py,sha256=Gy43bjrZTkfiYtQQZGZFvJwHvHS0PxhZCf8l-LRrbRE,168
34
+ mixpeek/types/csv_params.py,sha256=Adc3qwAOGpvRRAu3iV6ObN5EbLPnzmsj8IxTyDc0ZCM,938
35
+ mixpeek/types/destination.py,sha256=jU4igBU4bKOghQzW4msvZ3e-FydYcgKp_gdbJ0LVdWk,1113
36
+ mixpeek/types/embedding_response.py,sha256=lZc6MhLpcNFfb9p_I0FpQ2I7iqpL_xZB5a9jlvJeQ2I,1056
37
+ mixpeek/types/error_message.py,sha256=8Wh_GdH3jOviv_FYLyzQH20qbFTSzKqqjdZlOe2tlbE,905
38
+ mixpeek/types/error_response.py,sha256=SNectmi0OaoeWGAUvO7D0h40rf7jIEh3SLUtKxXs3ms,995
39
+ mixpeek/types/extract_response.py,sha256=gaNMOtfE5MkaUHtqLprP67TIO6LYSyJURwGVMWmv5mc,1184
40
+ mixpeek/types/field_type.py,sha256=ihpE7AL8NwS8mZ9ItVeK26KBmrIa0tLbCag96Pk4dqE,160
41
+ mixpeek/types/generation_response.py,sha256=dWqZoOfbZzNpEciX2_p46EHnY6fL1_gBjHcke2vdJ7c,1141
42
+ mixpeek/types/html_params.py,sha256=5wylzm01kSNgIgMFMGmgj93LCJpubrX0gp2NuKxjVYE,949
43
+ mixpeek/types/http_validation_error.py,sha256=C6i5Fm74cECbzWUDvUDgAO9g9ryIFeKesoeqTUNakJc,1010
44
+ mixpeek/types/image_params.py,sha256=zdeXR_-EGw_7MKOF1D2zilRFiYJWohDnLVTo1VwLa7U,1070
45
+ mixpeek/types/message.py,sha256=vvXf0byJJ4HWoAEyTyB1qnnSbu-H6OGIkv6ptDX-0R8,1057
46
+ mixpeek/types/metadata.py,sha256=Us5RgZ4WT-2RhpMLs8tjzP42P-ZrjRhYL0NNup0zvto,1047
47
+ mixpeek/types/modality.py,sha256=HwFmbfcJfBKLYg680oQLkGSiQETfNPqiB-mQO7X8sjA,102
48
+ mixpeek/types/model.py,sha256=2jcHm1qJhUaug0oB2vCi-2S1gCewsghhnBPeHg4Q_Xw,1076
49
+ mixpeek/types/models.py,sha256=RnTOybDVTkVIWrZRY18cULyqjGGTWE2ZJuYT0lYv5lo,173
50
+ mixpeek/types/pdf_params.py,sha256=9RF3S2uuE4oyaoPlRfI52phqWyD8ViOz6tl25HXBlek,1646
51
+ mixpeek/types/pipeline_response.py,sha256=dZZKcmG7kI8freXZNgrAq7NccatgGmsvkmw5ailk7-g,1577
52
+ mixpeek/types/pipeline_task_response.py,sha256=4We2MKw_vqOhh8ItCtkHNL2aL1W3lHaYVVd8KSnJUy0,975
53
+ mixpeek/types/ppt_params.py,sha256=FS9BjjiZStDhGtaImv8uz9lhQG6r6a9gBiUJsPzhca0,888
54
+ mixpeek/types/pptx_params.py,sha256=W2hrSVvYjRxDrClFRoZKmM0dSb0YbCOjjT5dBiJMkZw,889
55
+ mixpeek/types/settings.py,sha256=F_KpO1F5_yHyRXQr7SPn7QIjVa05ViiyXShlB_ODKsI,1223
56
+ mixpeek/types/source.py,sha256=T_C2UPZGJjHBemMrPa8XN05JVBzRUpbw2VykW4HXEs0,1181
57
+ mixpeek/types/source_destination_mapping.py,sha256=lLRKi4bM60oEuhny3MPbx2FIyRoWS1J8ZtwSRltSerU,1207
58
+ mixpeek/types/txt_params.py,sha256=nongbYA0BWr4kHvNBDdA6yoNkg6TXTsP2AG3tstyLd8,888
59
+ mixpeek/types/user.py,sha256=bZ4ROKzi-5c8pfHQ-nvM445m_d3p9DK-OjTbGhXY1-w,1249
60
+ mixpeek/types/validation_error.py,sha256=dy6Ev1xmAsX_Wcck5AX8XvcVNP5xA-Lwlt7FTceiYqs,1029
61
+ mixpeek/types/validation_error_loc_item.py,sha256=LAtjCHIllWRBFXvAZ5QZpp7CPXjdtN9EB7HrLVo6EP0,128
62
+ mixpeek/types/video_params.py,sha256=SJlONUkncIVzFz37Q8iNNznYd10hdLgrMnRmxT5yz5E,890
63
+ mixpeek/types/workflow_code_response.py,sha256=Ss20TnpKi43ql19PdSMJVCoDacyBQ3nMlUond0wgaYw,924
64
+ mixpeek/types/workflow_response.py,sha256=t3fhcd780TUiCbFmX-2hRQY9oajjdE6g8AOy-lVS95A,1059
65
+ mixpeek/types/workflow_settings.py,sha256=1YXWRIJUxra85keIOglvJra62rItRyuH8PYcG3pgRvE,1003
66
+ mixpeek/types/xlsx_params.py,sha256=SXGQe3KhevNEdxjqIxxHmmuBrrk4IBetEcFaHq-_zQA,939
67
+ mixpeek/user/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
68
+ mixpeek/user/client.py,sha256=pHLUkVtYVlTodDtPHBCuY3HOMra_kW7GWrrqHYCluq4,14785
69
+ mixpeek/version.py,sha256=DfAuS0W7koTv3v8TZFxY1W5LvfaqOvG96P6Kc5fNnU0,75
70
+ mixpeek/workflow/__init__.py,sha256=FTtvy8EDg9nNNg9WCatVgKTRYV8-_v1roeGPAKoa_pw,65
71
+ mixpeek/workflow/client.py,sha256=BbPm46yRHcUH8EJLnDrUpOv0iz98o8N3wiFIB93K494,24356
72
+ mixpeek-0.6.5.dist-info/LICENSE,sha256=4Wv5VxfDWkCcIouCfq1NrLwPm24Z83PE8Nbi3KyoEeg,1064
73
+ mixpeek-0.6.5.dist-info/METADATA,sha256=oHhR8hntHWa7Zp1gxEIR77Rp5HeajDKGIK_tCFHL_cg,3985
74
+ mixpeek-0.6.5.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
75
+ mixpeek-0.6.5.dist-info/RECORD,,
@@ -1,239 +0,0 @@
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.generation_response import GenerationResponse
20
- from ..types.http_validation_error import HttpValidationError
21
- from ..types.message import Message
22
- from ..types.model import Model
23
- from ..types.settings import Settings
24
-
25
- try:
26
- import pydantic.v1 as pydantic # type: ignore
27
- except ImportError:
28
- import pydantic # type: ignore
29
-
30
- # this is used as the default value for optional parameters
31
- OMIT = typing.cast(typing.Any, ...)
32
-
33
-
34
- class GeneratorsClient:
35
- def __init__(self, *, client_wrapper: SyncClientWrapper):
36
- self._client_wrapper = client_wrapper
37
-
38
- def generate(
39
- self,
40
- *,
41
- model: Model,
42
- response_format: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
43
- context: typing.Optional[str] = OMIT,
44
- messages: typing.Sequence[Message],
45
- settings: typing.Optional[Settings] = OMIT,
46
- request_options: typing.Optional[RequestOptions] = None,
47
- ) -> GenerationResponse:
48
- """
49
- Parameters:
50
- - model: Model.
51
-
52
- - response_format: typing.Optional[typing.Dict[str, typing.Any]].
53
-
54
- - context: typing.Optional[str].
55
-
56
- - messages: typing.Sequence[Message].
57
-
58
- - settings: typing.Optional[Settings].
59
-
60
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
61
- ---
62
- from mixpeek import Message, Model
63
- from mixpeek.client import Mixpeek
64
-
65
- client = Mixpeek(
66
- authorization="YOUR_AUTHORIZATION",
67
- index_id="YOUR_INDEX_ID",
68
- api_key="YOUR_API_KEY",
69
- base_url="https://yourhost.com/path/to/api",
70
- )
71
- client.generators.generate(
72
- model=Model(
73
- provider="provider",
74
- model="model",
75
- ),
76
- messages=[
77
- Message(
78
- role="role",
79
- content="content",
80
- )
81
- ],
82
- )
83
- """
84
- _request: typing.Dict[str, typing.Any] = {"model": model, "messages": messages}
85
- if response_format is not OMIT:
86
- _request["response_format"] = response_format
87
- if context is not OMIT:
88
- _request["context"] = context
89
- if settings is not OMIT:
90
- _request["settings"] = settings
91
- _response = self._client_wrapper.httpx_client.request(
92
- "POST",
93
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "generate"),
94
- params=jsonable_encoder(
95
- request_options.get("additional_query_parameters") if request_options is not None else None
96
- ),
97
- json=jsonable_encoder(_request)
98
- if request_options is None or request_options.get("additional_body_parameters") is None
99
- else {
100
- **jsonable_encoder(_request),
101
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
102
- },
103
- headers=jsonable_encoder(
104
- remove_none_from_dict(
105
- {
106
- **self._client_wrapper.get_headers(),
107
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
108
- }
109
- )
110
- ),
111
- timeout=request_options.get("timeout_in_seconds")
112
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
113
- else self._client_wrapper.get_timeout(),
114
- retries=0,
115
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
116
- )
117
- if 200 <= _response.status_code < 300:
118
- return pydantic.parse_obj_as(GenerationResponse, _response.json()) # type: ignore
119
- if _response.status_code == 400:
120
- raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
121
- if _response.status_code == 401:
122
- raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
123
- if _response.status_code == 403:
124
- raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
125
- if _response.status_code == 404:
126
- raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
127
- if _response.status_code == 422:
128
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
129
- if _response.status_code == 500:
130
- raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
131
- try:
132
- _response_json = _response.json()
133
- except JSONDecodeError:
134
- raise ApiError(status_code=_response.status_code, body=_response.text)
135
- raise ApiError(status_code=_response.status_code, body=_response_json)
136
-
137
-
138
- class AsyncGeneratorsClient:
139
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
140
- self._client_wrapper = client_wrapper
141
-
142
- async def generate(
143
- self,
144
- *,
145
- model: Model,
146
- response_format: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
147
- context: typing.Optional[str] = OMIT,
148
- messages: typing.Sequence[Message],
149
- settings: typing.Optional[Settings] = OMIT,
150
- request_options: typing.Optional[RequestOptions] = None,
151
- ) -> GenerationResponse:
152
- """
153
- Parameters:
154
- - model: Model.
155
-
156
- - response_format: typing.Optional[typing.Dict[str, typing.Any]].
157
-
158
- - context: typing.Optional[str].
159
-
160
- - messages: typing.Sequence[Message].
161
-
162
- - settings: typing.Optional[Settings].
163
-
164
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
165
- ---
166
- from mixpeek import Message, Model
167
- from mixpeek.client import AsyncMixpeek
168
-
169
- client = AsyncMixpeek(
170
- authorization="YOUR_AUTHORIZATION",
171
- index_id="YOUR_INDEX_ID",
172
- api_key="YOUR_API_KEY",
173
- base_url="https://yourhost.com/path/to/api",
174
- )
175
- await client.generators.generate(
176
- model=Model(
177
- provider="provider",
178
- model="model",
179
- ),
180
- messages=[
181
- Message(
182
- role="role",
183
- content="content",
184
- )
185
- ],
186
- )
187
- """
188
- _request: typing.Dict[str, typing.Any] = {"model": model, "messages": messages}
189
- if response_format is not OMIT:
190
- _request["response_format"] = response_format
191
- if context is not OMIT:
192
- _request["context"] = context
193
- if settings is not OMIT:
194
- _request["settings"] = settings
195
- _response = await self._client_wrapper.httpx_client.request(
196
- "POST",
197
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "generate"),
198
- params=jsonable_encoder(
199
- request_options.get("additional_query_parameters") if request_options is not None else None
200
- ),
201
- json=jsonable_encoder(_request)
202
- if request_options is None or request_options.get("additional_body_parameters") is None
203
- else {
204
- **jsonable_encoder(_request),
205
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
206
- },
207
- headers=jsonable_encoder(
208
- remove_none_from_dict(
209
- {
210
- **self._client_wrapper.get_headers(),
211
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
212
- }
213
- )
214
- ),
215
- timeout=request_options.get("timeout_in_seconds")
216
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
217
- else self._client_wrapper.get_timeout(),
218
- retries=0,
219
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
220
- )
221
- if 200 <= _response.status_code < 300:
222
- return pydantic.parse_obj_as(GenerationResponse, _response.json()) # type: ignore
223
- if _response.status_code == 400:
224
- raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
225
- if _response.status_code == 401:
226
- raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
227
- if _response.status_code == 403:
228
- raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
229
- if _response.status_code == 404:
230
- raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
231
- if _response.status_code == 422:
232
- raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
233
- if _response.status_code == 500:
234
- raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
235
- try:
236
- _response_json = _response.json()
237
- except JSONDecodeError:
238
- raise ApiError(status_code=_response.status_code, body=_response.text)
239
- raise ApiError(status_code=_response.status_code, body=_response_json)
mixpeek/parse/client.py DELETED
@@ -1,349 +0,0 @@
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)
mixpeek/parse_client.py DELETED
@@ -1,14 +0,0 @@
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