mixpeek 0.6.8__py3-none-any.whl → 0.6.9__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 (85) hide show
  1. mixpeek/__init__.py +1 -106
  2. mixpeek/client.py +21 -65
  3. mixpeek/endpoints/connections.py +16 -0
  4. mixpeek/endpoints/embed.py +50 -0
  5. mixpeek/endpoints/extract.py +16 -0
  6. mixpeek/endpoints/generate.py +17 -0
  7. mixpeek/endpoints/tools.py +23 -0
  8. mixpeek/exceptions.py +13 -0
  9. mixpeek-0.6.9.dist-info/METADATA +68 -0
  10. mixpeek-0.6.9.dist-info/RECORD +13 -0
  11. {mixpeek-0.6.8.dist-info → mixpeek-0.6.9.dist-info}/WHEEL +2 -1
  12. mixpeek-0.6.9.dist-info/top_level.txt +1 -0
  13. mixpeek/base_client.py +0 -1015
  14. mixpeek/core/__init__.py +0 -27
  15. mixpeek/core/api_error.py +0 -15
  16. mixpeek/core/client_wrapper.py +0 -83
  17. mixpeek/core/datetime_utils.py +0 -28
  18. mixpeek/core/file.py +0 -38
  19. mixpeek/core/http_client.py +0 -130
  20. mixpeek/core/jsonable_encoder.py +0 -99
  21. mixpeek/core/pydantic_utilities.py +0 -12
  22. mixpeek/core/remove_none_from_dict.py +0 -11
  23. mixpeek/core/request_options.py +0 -32
  24. mixpeek/environment.py +0 -7
  25. mixpeek/errors/__init__.py +0 -17
  26. mixpeek/errors/bad_request_error.py +0 -9
  27. mixpeek/errors/forbidden_error.py +0 -9
  28. mixpeek/errors/internal_server_error.py +0 -9
  29. mixpeek/errors/not_found_error.py +0 -9
  30. mixpeek/errors/unauthorized_error.py +0 -9
  31. mixpeek/errors/unprocessable_entity_error.py +0 -9
  32. mixpeek/pipeline/__init__.py +0 -2
  33. mixpeek/pipeline/client.py +0 -482
  34. mixpeek/storage/__init__.py +0 -5
  35. mixpeek/storage/client.py +0 -145
  36. mixpeek/storage/sample/__init__.py +0 -2
  37. mixpeek/storage/sample/client.py +0 -286
  38. mixpeek/types/__init__.py +0 -81
  39. mixpeek/types/api_key.py +0 -27
  40. mixpeek/types/audio_params.py +0 -25
  41. mixpeek/types/configs_response.py +0 -38
  42. mixpeek/types/connection.py +0 -32
  43. mixpeek/types/connection_engine.py +0 -5
  44. mixpeek/types/csv_params.py +0 -25
  45. mixpeek/types/destination.py +0 -38
  46. mixpeek/types/embedding_response.py +0 -30
  47. mixpeek/types/error_message.py +0 -25
  48. mixpeek/types/error_response.py +0 -26
  49. mixpeek/types/extract_response.py +0 -31
  50. mixpeek/types/field_type.py +0 -5
  51. mixpeek/types/generation_response.py +0 -32
  52. mixpeek/types/html_params.py +0 -25
  53. mixpeek/types/http_validation_error.py +0 -26
  54. mixpeek/types/image_params.py +0 -28
  55. mixpeek/types/message.py +0 -33
  56. mixpeek/types/metadata.py +0 -28
  57. mixpeek/types/modality.py +0 -5
  58. mixpeek/types/model.py +0 -34
  59. mixpeek/types/models.py +0 -5
  60. mixpeek/types/pdf_params.py +0 -37
  61. mixpeek/types/pipeline_response.py +0 -45
  62. mixpeek/types/pipeline_task_response.py +0 -28
  63. mixpeek/types/ppt_params.py +0 -23
  64. mixpeek/types/pptx_params.py +0 -23
  65. mixpeek/types/settings.py +0 -31
  66. mixpeek/types/source.py +0 -39
  67. mixpeek/types/source_destination_mapping.py +0 -40
  68. mixpeek/types/txt_params.py +0 -23
  69. mixpeek/types/user.py +0 -32
  70. mixpeek/types/validation_error.py +0 -28
  71. mixpeek/types/validation_error_loc_item.py +0 -5
  72. mixpeek/types/video_params.py +0 -23
  73. mixpeek/types/workflow_code_response.py +0 -25
  74. mixpeek/types/workflow_response.py +0 -28
  75. mixpeek/types/workflow_settings.py +0 -26
  76. mixpeek/types/xlsx_params.py +0 -25
  77. mixpeek/user/__init__.py +0 -2
  78. mixpeek/user/client.py +0 -312
  79. mixpeek/version.py +0 -4
  80. mixpeek/workflow/__init__.py +0 -2
  81. mixpeek/workflow/client.py +0 -543
  82. mixpeek-0.6.8.dist-info/LICENSE +0 -21
  83. mixpeek-0.6.8.dist-info/METADATA +0 -145
  84. mixpeek-0.6.8.dist-info/RECORD +0 -76
  85. /mixpeek/{py.typed → endpoints/__init__.py} +0 -0
@@ -1,543 +0,0 @@
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.pydantic_utilities import pydantic_v1
12
- from ..core.remove_none_from_dict import remove_none_from_dict
13
- from ..core.request_options import RequestOptions
14
- from ..errors.bad_request_error import BadRequestError
15
- from ..errors.forbidden_error import ForbiddenError
16
- from ..errors.internal_server_error import InternalServerError
17
- from ..errors.not_found_error import NotFoundError
18
- from ..errors.unauthorized_error import UnauthorizedError
19
- from ..errors.unprocessable_entity_error import UnprocessableEntityError
20
- from ..types.error_response import ErrorResponse
21
- from ..types.http_validation_error import HttpValidationError
22
- from ..types.workflow_code_response import WorkflowCodeResponse
23
- from ..types.workflow_response import WorkflowResponse
24
- from ..types.workflow_settings import WorkflowSettings
25
-
26
- # this is used as the default value for optional parameters
27
- OMIT = typing.cast(typing.Any, ...)
28
-
29
-
30
- class WorkflowClient:
31
- def __init__(self, *, client_wrapper: SyncClientWrapper):
32
- self._client_wrapper = client_wrapper
33
-
34
- def create(
35
- self,
36
- *,
37
- workflow_id: typing.Optional[str] = OMIT,
38
- code_as_string: str,
39
- metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
40
- settings: WorkflowSettings,
41
- workflow_name: typing.Optional[str] = OMIT,
42
- last_run: typing.Optional[dt.datetime] = OMIT,
43
- created_at: typing.Optional[dt.datetime] = OMIT,
44
- request_options: typing.Optional[RequestOptions] = None,
45
- ) -> WorkflowResponse:
46
- """
47
- Parameters:
48
- - workflow_id: typing.Optional[str].
49
-
50
- - code_as_string: str.
51
-
52
- - metadata: typing.Optional[typing.Dict[str, typing.Any]].
53
-
54
- - settings: WorkflowSettings.
55
-
56
- - workflow_name: typing.Optional[str].
57
-
58
- - last_run: typing.Optional[dt.datetime].
59
-
60
- - created_at: typing.Optional[dt.datetime].
61
-
62
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
63
- ---
64
- from mixpeek import WorkflowSettings
65
- from mixpeek.client import Mixpeek
66
-
67
- client = Mixpeek(
68
- authorization="YOUR_AUTHORIZATION",
69
- index_id="YOUR_INDEX_ID",
70
- api_key="YOUR_API_KEY",
71
- )
72
- client.workflow.create(
73
- code_as_string="code_as_string",
74
- settings=WorkflowSettings(),
75
- )
76
- """
77
- _request: typing.Dict[str, typing.Any] = {"code_as_string": code_as_string, "settings": settings}
78
- if workflow_id is not OMIT:
79
- _request["workflow_id"] = workflow_id
80
- if metadata is not OMIT:
81
- _request["metadata"] = metadata
82
- if workflow_name is not OMIT:
83
- _request["workflow_name"] = workflow_name
84
- if last_run is not OMIT:
85
- _request["last_run"] = last_run
86
- if created_at is not OMIT:
87
- _request["created_at"] = created_at
88
- _response = self._client_wrapper.httpx_client.request(
89
- "POST",
90
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "workflows"),
91
- params=jsonable_encoder(
92
- request_options.get("additional_query_parameters") if request_options is not None else None
93
- ),
94
- json=jsonable_encoder(_request)
95
- if request_options is None or request_options.get("additional_body_parameters") is None
96
- else {
97
- **jsonable_encoder(_request),
98
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
99
- },
100
- headers=jsonable_encoder(
101
- remove_none_from_dict(
102
- {
103
- **self._client_wrapper.get_headers(),
104
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
105
- }
106
- )
107
- ),
108
- timeout=request_options.get("timeout_in_seconds")
109
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
110
- else self._client_wrapper.get_timeout(),
111
- retries=0,
112
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
113
- )
114
- if 200 <= _response.status_code < 300:
115
- return pydantic_v1.parse_obj_as(WorkflowResponse, _response.json()) # type: ignore
116
- if _response.status_code == 400:
117
- raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
118
- if _response.status_code == 401:
119
- raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
120
- if _response.status_code == 403:
121
- raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
122
- if _response.status_code == 404:
123
- raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
124
- if _response.status_code == 422:
125
- raise UnprocessableEntityError(
126
- pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
127
- )
128
- if _response.status_code == 500:
129
- raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
130
- try:
131
- _response_json = _response.json()
132
- except JSONDecodeError:
133
- raise ApiError(status_code=_response.status_code, body=_response.text)
134
- raise ApiError(status_code=_response.status_code, body=_response_json)
135
-
136
- def invoke(
137
- self,
138
- workflow_id: str,
139
- *,
140
- websocket_id: typing.Optional[str] = None,
141
- request: typing.Dict[str, typing.Any],
142
- request_options: typing.Optional[RequestOptions] = None,
143
- ) -> typing.Any:
144
- """
145
- Parameters:
146
- - workflow_id: str.
147
-
148
- - websocket_id: typing.Optional[str].
149
-
150
- - request: typing.Dict[str, typing.Any].
151
-
152
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
153
- ---
154
- from mixpeek.client import Mixpeek
155
-
156
- client = Mixpeek(
157
- authorization="YOUR_AUTHORIZATION",
158
- index_id="YOUR_INDEX_ID",
159
- api_key="YOUR_API_KEY",
160
- )
161
- client.workflow.invoke(
162
- workflow_id="workflow_id",
163
- request={},
164
- )
165
- """
166
- _response = self._client_wrapper.httpx_client.request(
167
- "POST",
168
- urllib.parse.urljoin(
169
- f"{self._client_wrapper.get_base_url()}/", f"workflows/{jsonable_encoder(workflow_id)}/invoke"
170
- ),
171
- params=jsonable_encoder(
172
- remove_none_from_dict(
173
- {
174
- "websocket_id": websocket_id,
175
- **(
176
- request_options.get("additional_query_parameters", {})
177
- if request_options is not None
178
- else {}
179
- ),
180
- }
181
- )
182
- ),
183
- json=jsonable_encoder(request)
184
- if request_options is None or request_options.get("additional_body_parameters") is None
185
- else {
186
- **jsonable_encoder(request),
187
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
188
- },
189
- headers=jsonable_encoder(
190
- remove_none_from_dict(
191
- {
192
- **self._client_wrapper.get_headers(),
193
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
194
- }
195
- )
196
- ),
197
- timeout=request_options.get("timeout_in_seconds")
198
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
199
- else self._client_wrapper.get_timeout(),
200
- retries=0,
201
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
202
- )
203
- if 200 <= _response.status_code < 300:
204
- return pydantic_v1.parse_obj_as(typing.Any, _response.json()) # type: ignore
205
- if _response.status_code == 400:
206
- raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
207
- if _response.status_code == 401:
208
- raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
209
- if _response.status_code == 403:
210
- raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
211
- if _response.status_code == 404:
212
- raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
213
- if _response.status_code == 422:
214
- raise UnprocessableEntityError(
215
- pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
216
- )
217
- if _response.status_code == 500:
218
- raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
219
- try:
220
- _response_json = _response.json()
221
- except JSONDecodeError:
222
- raise ApiError(status_code=_response.status_code, body=_response.text)
223
- raise ApiError(status_code=_response.status_code, body=_response_json)
224
-
225
- def code(self, *, request: str, request_options: typing.Optional[RequestOptions] = None) -> WorkflowCodeResponse:
226
- """
227
- Parameters:
228
- - request: str.
229
-
230
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
231
- ---
232
- from mixpeek.client import Mixpeek
233
-
234
- client = Mixpeek(
235
- authorization="YOUR_AUTHORIZATION",
236
- index_id="YOUR_INDEX_ID",
237
- api_key="YOUR_API_KEY",
238
- )
239
- client.workflow.code(
240
- request="string",
241
- )
242
- """
243
- _response = self._client_wrapper.httpx_client.request(
244
- "POST",
245
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "workflows/code"),
246
- params=jsonable_encoder(
247
- request_options.get("additional_query_parameters") if request_options is not None else None
248
- ),
249
- json=jsonable_encoder(request),
250
- headers=jsonable_encoder(
251
- remove_none_from_dict(
252
- {
253
- **self._client_wrapper.get_headers(),
254
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
255
- }
256
- )
257
- ),
258
- timeout=request_options.get("timeout_in_seconds")
259
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
260
- else self._client_wrapper.get_timeout(),
261
- retries=0,
262
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
263
- )
264
- if 200 <= _response.status_code < 300:
265
- return pydantic_v1.parse_obj_as(WorkflowCodeResponse, _response.json()) # type: ignore
266
- if _response.status_code == 400:
267
- raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
268
- if _response.status_code == 401:
269
- raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
270
- if _response.status_code == 403:
271
- raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
272
- if _response.status_code == 404:
273
- raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
274
- if _response.status_code == 422:
275
- raise UnprocessableEntityError(
276
- pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
277
- )
278
- if _response.status_code == 500:
279
- raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
280
- try:
281
- _response_json = _response.json()
282
- except JSONDecodeError:
283
- raise ApiError(status_code=_response.status_code, body=_response.text)
284
- raise ApiError(status_code=_response.status_code, body=_response_json)
285
-
286
-
287
- class AsyncWorkflowClient:
288
- def __init__(self, *, client_wrapper: AsyncClientWrapper):
289
- self._client_wrapper = client_wrapper
290
-
291
- async def create(
292
- self,
293
- *,
294
- workflow_id: typing.Optional[str] = OMIT,
295
- code_as_string: str,
296
- metadata: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
297
- settings: WorkflowSettings,
298
- workflow_name: typing.Optional[str] = OMIT,
299
- last_run: typing.Optional[dt.datetime] = OMIT,
300
- created_at: typing.Optional[dt.datetime] = OMIT,
301
- request_options: typing.Optional[RequestOptions] = None,
302
- ) -> WorkflowResponse:
303
- """
304
- Parameters:
305
- - workflow_id: typing.Optional[str].
306
-
307
- - code_as_string: str.
308
-
309
- - metadata: typing.Optional[typing.Dict[str, typing.Any]].
310
-
311
- - settings: WorkflowSettings.
312
-
313
- - workflow_name: typing.Optional[str].
314
-
315
- - last_run: typing.Optional[dt.datetime].
316
-
317
- - created_at: typing.Optional[dt.datetime].
318
-
319
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
320
- ---
321
- from mixpeek import WorkflowSettings
322
- from mixpeek.client import AsyncMixpeek
323
-
324
- client = AsyncMixpeek(
325
- authorization="YOUR_AUTHORIZATION",
326
- index_id="YOUR_INDEX_ID",
327
- api_key="YOUR_API_KEY",
328
- )
329
- await client.workflow.create(
330
- code_as_string="code_as_string",
331
- settings=WorkflowSettings(),
332
- )
333
- """
334
- _request: typing.Dict[str, typing.Any] = {"code_as_string": code_as_string, "settings": settings}
335
- if workflow_id is not OMIT:
336
- _request["workflow_id"] = workflow_id
337
- if metadata is not OMIT:
338
- _request["metadata"] = metadata
339
- if workflow_name is not OMIT:
340
- _request["workflow_name"] = workflow_name
341
- if last_run is not OMIT:
342
- _request["last_run"] = last_run
343
- if created_at is not OMIT:
344
- _request["created_at"] = created_at
345
- _response = await self._client_wrapper.httpx_client.request(
346
- "POST",
347
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "workflows"),
348
- params=jsonable_encoder(
349
- request_options.get("additional_query_parameters") if request_options is not None else None
350
- ),
351
- json=jsonable_encoder(_request)
352
- if request_options is None or request_options.get("additional_body_parameters") is None
353
- else {
354
- **jsonable_encoder(_request),
355
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
356
- },
357
- headers=jsonable_encoder(
358
- remove_none_from_dict(
359
- {
360
- **self._client_wrapper.get_headers(),
361
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
362
- }
363
- )
364
- ),
365
- timeout=request_options.get("timeout_in_seconds")
366
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
367
- else self._client_wrapper.get_timeout(),
368
- retries=0,
369
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
370
- )
371
- if 200 <= _response.status_code < 300:
372
- return pydantic_v1.parse_obj_as(WorkflowResponse, _response.json()) # type: ignore
373
- if _response.status_code == 400:
374
- raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
375
- if _response.status_code == 401:
376
- raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
377
- if _response.status_code == 403:
378
- raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
379
- if _response.status_code == 404:
380
- raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
381
- if _response.status_code == 422:
382
- raise UnprocessableEntityError(
383
- pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
384
- )
385
- if _response.status_code == 500:
386
- raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
387
- try:
388
- _response_json = _response.json()
389
- except JSONDecodeError:
390
- raise ApiError(status_code=_response.status_code, body=_response.text)
391
- raise ApiError(status_code=_response.status_code, body=_response_json)
392
-
393
- async def invoke(
394
- self,
395
- workflow_id: str,
396
- *,
397
- websocket_id: typing.Optional[str] = None,
398
- request: typing.Dict[str, typing.Any],
399
- request_options: typing.Optional[RequestOptions] = None,
400
- ) -> typing.Any:
401
- """
402
- Parameters:
403
- - workflow_id: str.
404
-
405
- - websocket_id: typing.Optional[str].
406
-
407
- - request: typing.Dict[str, typing.Any].
408
-
409
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
410
- ---
411
- from mixpeek.client import AsyncMixpeek
412
-
413
- client = AsyncMixpeek(
414
- authorization="YOUR_AUTHORIZATION",
415
- index_id="YOUR_INDEX_ID",
416
- api_key="YOUR_API_KEY",
417
- )
418
- await client.workflow.invoke(
419
- workflow_id="workflow_id",
420
- request={},
421
- )
422
- """
423
- _response = await self._client_wrapper.httpx_client.request(
424
- "POST",
425
- urllib.parse.urljoin(
426
- f"{self._client_wrapper.get_base_url()}/", f"workflows/{jsonable_encoder(workflow_id)}/invoke"
427
- ),
428
- params=jsonable_encoder(
429
- remove_none_from_dict(
430
- {
431
- "websocket_id": websocket_id,
432
- **(
433
- request_options.get("additional_query_parameters", {})
434
- if request_options is not None
435
- else {}
436
- ),
437
- }
438
- )
439
- ),
440
- json=jsonable_encoder(request)
441
- if request_options is None or request_options.get("additional_body_parameters") is None
442
- else {
443
- **jsonable_encoder(request),
444
- **(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
445
- },
446
- headers=jsonable_encoder(
447
- remove_none_from_dict(
448
- {
449
- **self._client_wrapper.get_headers(),
450
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
451
- }
452
- )
453
- ),
454
- timeout=request_options.get("timeout_in_seconds")
455
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
456
- else self._client_wrapper.get_timeout(),
457
- retries=0,
458
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
459
- )
460
- if 200 <= _response.status_code < 300:
461
- return pydantic_v1.parse_obj_as(typing.Any, _response.json()) # type: ignore
462
- if _response.status_code == 400:
463
- raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
464
- if _response.status_code == 401:
465
- raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
466
- if _response.status_code == 403:
467
- raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
468
- if _response.status_code == 404:
469
- raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
470
- if _response.status_code == 422:
471
- raise UnprocessableEntityError(
472
- pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
473
- )
474
- if _response.status_code == 500:
475
- raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
476
- try:
477
- _response_json = _response.json()
478
- except JSONDecodeError:
479
- raise ApiError(status_code=_response.status_code, body=_response.text)
480
- raise ApiError(status_code=_response.status_code, body=_response_json)
481
-
482
- async def code(
483
- self, *, request: str, request_options: typing.Optional[RequestOptions] = None
484
- ) -> WorkflowCodeResponse:
485
- """
486
- Parameters:
487
- - request: str.
488
-
489
- - request_options: typing.Optional[RequestOptions]. Request-specific configuration.
490
- ---
491
- from mixpeek.client import AsyncMixpeek
492
-
493
- client = AsyncMixpeek(
494
- authorization="YOUR_AUTHORIZATION",
495
- index_id="YOUR_INDEX_ID",
496
- api_key="YOUR_API_KEY",
497
- )
498
- await client.workflow.code(
499
- request="string",
500
- )
501
- """
502
- _response = await self._client_wrapper.httpx_client.request(
503
- "POST",
504
- urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "workflows/code"),
505
- params=jsonable_encoder(
506
- request_options.get("additional_query_parameters") if request_options is not None else None
507
- ),
508
- json=jsonable_encoder(request),
509
- headers=jsonable_encoder(
510
- remove_none_from_dict(
511
- {
512
- **self._client_wrapper.get_headers(),
513
- **(request_options.get("additional_headers", {}) if request_options is not None else {}),
514
- }
515
- )
516
- ),
517
- timeout=request_options.get("timeout_in_seconds")
518
- if request_options is not None and request_options.get("timeout_in_seconds") is not None
519
- else self._client_wrapper.get_timeout(),
520
- retries=0,
521
- max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
522
- )
523
- if 200 <= _response.status_code < 300:
524
- return pydantic_v1.parse_obj_as(WorkflowCodeResponse, _response.json()) # type: ignore
525
- if _response.status_code == 400:
526
- raise BadRequestError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
527
- if _response.status_code == 401:
528
- raise UnauthorizedError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
529
- if _response.status_code == 403:
530
- raise ForbiddenError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
531
- if _response.status_code == 404:
532
- raise NotFoundError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
533
- if _response.status_code == 422:
534
- raise UnprocessableEntityError(
535
- pydantic_v1.parse_obj_as(HttpValidationError, _response.json()) # type: ignore
536
- )
537
- if _response.status_code == 500:
538
- raise InternalServerError(pydantic_v1.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
539
- try:
540
- _response_json = _response.json()
541
- except JSONDecodeError:
542
- raise ApiError(status_code=_response.status_code, body=_response.text)
543
- raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Mixpeek.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
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
13
- copies or substantial portions of the Software.
14
-
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.