mixpeek 0.6.1__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.
- mixpeek/__init__.py +18 -13
- mixpeek/base_client.py +39 -12
- mixpeek/core/client_wrapper.py +1 -1
- mixpeek/embed/__init__.py +2 -0
- mixpeek/embed/client.py +350 -0
- mixpeek/environment.py +7 -0
- mixpeek/extract/__init__.py +2 -0
- mixpeek/extract/client.py +347 -0
- mixpeek/generators/client.py +2 -4
- mixpeek/parse/client.py +10 -248
- mixpeek/pipelines/client.py +45 -123
- mixpeek/storage/client.py +0 -4
- mixpeek/types/__init__.py +12 -12
- mixpeek/types/{configs_request.py → api_key.py} +4 -4
- mixpeek/types/connection.py +1 -1
- mixpeek/types/{destination_schema.py → destination.py} +3 -3
- mixpeek/types/field_type.py +1 -1
- mixpeek/types/model.py +2 -1
- mixpeek/types/models.py +5 -0
- mixpeek/types/{field_schema.py → source.py} +3 -4
- mixpeek/types/{source_schema.py → source_destination_mapping.py} +6 -5
- mixpeek/types/{pipeline_response.py → user.py} +7 -10
- mixpeek/users/__init__.py +2 -0
- mixpeek/users/client.py +308 -0
- mixpeek/workflows/client.py +122 -4
- {mixpeek-0.6.1.dist-info → mixpeek-0.6.2.dist-info}/METADATA +1 -1
- {mixpeek-0.6.1.dist-info → mixpeek-0.6.2.dist-info}/RECORD +29 -22
- mixpeek/types/embedding_request.py +0 -32
- {mixpeek-0.6.1.dist-info → mixpeek-0.6.2.dist-info}/LICENSE +0 -0
- {mixpeek-0.6.1.dist-info → mixpeek-0.6.2.dist-info}/WHEEL +0 -0
mixpeek/__init__.py
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
2
2
|
|
3
3
|
from .types import (
|
4
|
+
ApiKey,
|
4
5
|
AudioParams,
|
5
|
-
ConfigsRequest,
|
6
6
|
ConfigsResponse,
|
7
7
|
Connection,
|
8
8
|
ConnectionEngine,
|
9
9
|
CsvParams,
|
10
|
-
|
11
|
-
EmbeddingRequest,
|
10
|
+
Destination,
|
12
11
|
EmbeddingResponse,
|
13
12
|
ErrorMessage,
|
14
13
|
ErrorResponse,
|
15
|
-
FieldSchema,
|
16
14
|
FieldType,
|
17
15
|
GenerationResponse,
|
18
16
|
HtmlParams,
|
@@ -22,13 +20,15 @@ from .types import (
|
|
22
20
|
Metadata,
|
23
21
|
Modality,
|
24
22
|
Model,
|
23
|
+
Models,
|
25
24
|
PdfParams,
|
26
|
-
PipelineResponse,
|
27
25
|
PptParams,
|
28
26
|
PptxParams,
|
29
27
|
Settings,
|
30
|
-
|
28
|
+
Source,
|
29
|
+
SourceDestinationMapping,
|
31
30
|
TxtParams,
|
31
|
+
User,
|
32
32
|
ValidationError,
|
33
33
|
ValidationErrorLocItem,
|
34
34
|
VideoParams,
|
@@ -44,23 +44,22 @@ from .errors import (
|
|
44
44
|
UnauthorizedError,
|
45
45
|
UnprocessableEntityError,
|
46
46
|
)
|
47
|
-
from . import generators, parse, pipelines, storage, workflows
|
47
|
+
from . import embed, extract, generators, parse, pipelines, storage, users, workflows
|
48
|
+
from .environment import MixpeekEnvironment
|
48
49
|
from .version import __version__
|
49
50
|
|
50
51
|
__all__ = [
|
52
|
+
"ApiKey",
|
51
53
|
"AudioParams",
|
52
54
|
"BadRequestError",
|
53
|
-
"ConfigsRequest",
|
54
55
|
"ConfigsResponse",
|
55
56
|
"Connection",
|
56
57
|
"ConnectionEngine",
|
57
58
|
"CsvParams",
|
58
|
-
"
|
59
|
-
"EmbeddingRequest",
|
59
|
+
"Destination",
|
60
60
|
"EmbeddingResponse",
|
61
61
|
"ErrorMessage",
|
62
62
|
"ErrorResponse",
|
63
|
-
"FieldSchema",
|
64
63
|
"FieldType",
|
65
64
|
"ForbiddenError",
|
66
65
|
"GenerationResponse",
|
@@ -70,18 +69,21 @@ __all__ = [
|
|
70
69
|
"InternalServerError",
|
71
70
|
"Message",
|
72
71
|
"Metadata",
|
72
|
+
"MixpeekEnvironment",
|
73
73
|
"Modality",
|
74
74
|
"Model",
|
75
|
+
"Models",
|
75
76
|
"NotFoundError",
|
76
77
|
"PdfParams",
|
77
|
-
"PipelineResponse",
|
78
78
|
"PptParams",
|
79
79
|
"PptxParams",
|
80
80
|
"Settings",
|
81
|
-
"
|
81
|
+
"Source",
|
82
|
+
"SourceDestinationMapping",
|
82
83
|
"TxtParams",
|
83
84
|
"UnauthorizedError",
|
84
85
|
"UnprocessableEntityError",
|
86
|
+
"User",
|
85
87
|
"ValidationError",
|
86
88
|
"ValidationErrorLocItem",
|
87
89
|
"VideoParams",
|
@@ -89,9 +91,12 @@ __all__ = [
|
|
89
91
|
"WorkflowSettings",
|
90
92
|
"XlsxParams",
|
91
93
|
"__version__",
|
94
|
+
"embed",
|
95
|
+
"extract",
|
92
96
|
"generators",
|
93
97
|
"parse",
|
94
98
|
"pipelines",
|
95
99
|
"storage",
|
100
|
+
"users",
|
96
101
|
"workflows",
|
97
102
|
]
|
mixpeek/base_client.py
CHANGED
@@ -7,10 +7,14 @@ import httpx
|
|
7
7
|
|
8
8
|
from .core.api_error import ApiError
|
9
9
|
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
10
|
+
from .embed.client import AsyncEmbedClient, EmbedClient
|
11
|
+
from .environment import MixpeekEnvironment
|
12
|
+
from .extract.client import AsyncExtractClient, ExtractClient
|
10
13
|
from .generators.client import AsyncGeneratorsClient, GeneratorsClient
|
11
14
|
from .parse.client import AsyncParseClient, ParseClient
|
12
15
|
from .pipelines.client import AsyncPipelinesClient, PipelinesClient
|
13
16
|
from .storage.client import AsyncStorageClient, StorageClient
|
17
|
+
from .users.client import AsyncUsersClient, UsersClient
|
14
18
|
from .workflows.client import AsyncWorkflowsClient, WorkflowsClient
|
15
19
|
|
16
20
|
|
@@ -19,7 +23,11 @@ class BaseMixpeek:
|
|
19
23
|
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions.
|
20
24
|
|
21
25
|
Parameters:
|
22
|
-
- base_url: str. The base url to use for requests from the client.
|
26
|
+
- base_url: typing.Optional[str]. The base url to use for requests from the client.
|
27
|
+
|
28
|
+
- environment: MixpeekEnvironment. The environment to use for requests from the client. from .environment import MixpeekEnvironment
|
29
|
+
|
30
|
+
Defaults to MixpeekEnvironment.DEFAULT
|
23
31
|
|
24
32
|
- authorization: typing.Optional[str].
|
25
33
|
|
@@ -37,14 +45,14 @@ class BaseMixpeek:
|
|
37
45
|
authorization="YOUR_AUTHORIZATION",
|
38
46
|
index_id="YOUR_INDEX_ID",
|
39
47
|
api_key="YOUR_API_KEY",
|
40
|
-
base_url="https://yourhost.com/path/to/api",
|
41
48
|
)
|
42
49
|
"""
|
43
50
|
|
44
51
|
def __init__(
|
45
52
|
self,
|
46
53
|
*,
|
47
|
-
base_url: str,
|
54
|
+
base_url: typing.Optional[str] = None,
|
55
|
+
environment: MixpeekEnvironment = MixpeekEnvironment.DEFAULT,
|
48
56
|
authorization: typing.Optional[str] = None,
|
49
57
|
index_id: typing.Optional[str] = None,
|
50
58
|
api_key: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv("MIXPEEK_API_KEY"),
|
@@ -57,18 +65,21 @@ class BaseMixpeek:
|
|
57
65
|
body="The client must be instantiated be either passing in api_key or setting MIXPEEK_API_KEY"
|
58
66
|
)
|
59
67
|
self._client_wrapper = SyncClientWrapper(
|
60
|
-
base_url=base_url,
|
68
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
61
69
|
authorization=authorization,
|
62
70
|
index_id=index_id,
|
63
71
|
api_key=api_key,
|
64
72
|
httpx_client=httpx.Client(timeout=_defaulted_timeout) if httpx_client is None else httpx_client,
|
65
73
|
timeout=_defaulted_timeout,
|
66
74
|
)
|
75
|
+
self.users = UsersClient(client_wrapper=self._client_wrapper)
|
76
|
+
self.extract = ExtractClient(client_wrapper=self._client_wrapper)
|
77
|
+
self.generators = GeneratorsClient(client_wrapper=self._client_wrapper)
|
78
|
+
self.embed = EmbedClient(client_wrapper=self._client_wrapper)
|
67
79
|
self.pipelines = PipelinesClient(client_wrapper=self._client_wrapper)
|
68
|
-
self.parse = ParseClient(client_wrapper=self._client_wrapper)
|
69
80
|
self.workflows = WorkflowsClient(client_wrapper=self._client_wrapper)
|
70
|
-
self.generators = GeneratorsClient(client_wrapper=self._client_wrapper)
|
71
81
|
self.storage = StorageClient(client_wrapper=self._client_wrapper)
|
82
|
+
self.parse = ParseClient(client_wrapper=self._client_wrapper)
|
72
83
|
|
73
84
|
|
74
85
|
class AsyncBaseMixpeek:
|
@@ -76,7 +87,11 @@ class AsyncBaseMixpeek:
|
|
76
87
|
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propogate to these functions.
|
77
88
|
|
78
89
|
Parameters:
|
79
|
-
- base_url: str. The base url to use for requests from the client.
|
90
|
+
- base_url: typing.Optional[str]. The base url to use for requests from the client.
|
91
|
+
|
92
|
+
- environment: MixpeekEnvironment. The environment to use for requests from the client. from .environment import MixpeekEnvironment
|
93
|
+
|
94
|
+
Defaults to MixpeekEnvironment.DEFAULT
|
80
95
|
|
81
96
|
- authorization: typing.Optional[str].
|
82
97
|
|
@@ -94,14 +109,14 @@ class AsyncBaseMixpeek:
|
|
94
109
|
authorization="YOUR_AUTHORIZATION",
|
95
110
|
index_id="YOUR_INDEX_ID",
|
96
111
|
api_key="YOUR_API_KEY",
|
97
|
-
base_url="https://yourhost.com/path/to/api",
|
98
112
|
)
|
99
113
|
"""
|
100
114
|
|
101
115
|
def __init__(
|
102
116
|
self,
|
103
117
|
*,
|
104
|
-
base_url: str,
|
118
|
+
base_url: typing.Optional[str] = None,
|
119
|
+
environment: MixpeekEnvironment = MixpeekEnvironment.DEFAULT,
|
105
120
|
authorization: typing.Optional[str] = None,
|
106
121
|
index_id: typing.Optional[str] = None,
|
107
122
|
api_key: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv("MIXPEEK_API_KEY"),
|
@@ -114,15 +129,27 @@ class AsyncBaseMixpeek:
|
|
114
129
|
body="The client must be instantiated be either passing in api_key or setting MIXPEEK_API_KEY"
|
115
130
|
)
|
116
131
|
self._client_wrapper = AsyncClientWrapper(
|
117
|
-
base_url=base_url,
|
132
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
118
133
|
authorization=authorization,
|
119
134
|
index_id=index_id,
|
120
135
|
api_key=api_key,
|
121
136
|
httpx_client=httpx.AsyncClient(timeout=_defaulted_timeout) if httpx_client is None else httpx_client,
|
122
137
|
timeout=_defaulted_timeout,
|
123
138
|
)
|
139
|
+
self.users = AsyncUsersClient(client_wrapper=self._client_wrapper)
|
140
|
+
self.extract = AsyncExtractClient(client_wrapper=self._client_wrapper)
|
141
|
+
self.generators = AsyncGeneratorsClient(client_wrapper=self._client_wrapper)
|
142
|
+
self.embed = AsyncEmbedClient(client_wrapper=self._client_wrapper)
|
124
143
|
self.pipelines = AsyncPipelinesClient(client_wrapper=self._client_wrapper)
|
125
|
-
self.parse = AsyncParseClient(client_wrapper=self._client_wrapper)
|
126
144
|
self.workflows = AsyncWorkflowsClient(client_wrapper=self._client_wrapper)
|
127
|
-
self.generators = AsyncGeneratorsClient(client_wrapper=self._client_wrapper)
|
128
145
|
self.storage = AsyncStorageClient(client_wrapper=self._client_wrapper)
|
146
|
+
self.parse = AsyncParseClient(client_wrapper=self._client_wrapper)
|
147
|
+
|
148
|
+
|
149
|
+
def _get_base_url(*, base_url: typing.Optional[str] = None, environment: MixpeekEnvironment) -> str:
|
150
|
+
if base_url is not None:
|
151
|
+
return base_url
|
152
|
+
elif environment is not None:
|
153
|
+
return environment.value
|
154
|
+
else:
|
155
|
+
raise Exception("Please pass in either base_url or environment to construct the client")
|
mixpeek/core/client_wrapper.py
CHANGED
@@ -27,7 +27,7 @@ class BaseClientWrapper:
|
|
27
27
|
headers: typing.Dict[str, str] = {
|
28
28
|
"X-Fern-Language": "Python",
|
29
29
|
"X-Fern-SDK-Name": "mixpeek",
|
30
|
-
"X-Fern-SDK-Version": "0.6.
|
30
|
+
"X-Fern-SDK-Version": "0.6.2",
|
31
31
|
}
|
32
32
|
if self._authorization is not None:
|
33
33
|
headers["Authorization"] = self._authorization
|
mixpeek/embed/client.py
ADDED
@@ -0,0 +1,350 @@
|
|
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.configs_response import ConfigsResponse
|
19
|
+
from ..types.embedding_response import EmbeddingResponse
|
20
|
+
from ..types.error_response import ErrorResponse
|
21
|
+
from ..types.http_validation_error import HttpValidationError
|
22
|
+
from ..types.modality import Modality
|
23
|
+
|
24
|
+
try:
|
25
|
+
import pydantic.v1 as pydantic # type: ignore
|
26
|
+
except ImportError:
|
27
|
+
import pydantic # type: ignore
|
28
|
+
|
29
|
+
# this is used as the default value for optional parameters
|
30
|
+
OMIT = typing.cast(typing.Any, ...)
|
31
|
+
|
32
|
+
|
33
|
+
class EmbedClient:
|
34
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
35
|
+
self._client_wrapper = client_wrapper
|
36
|
+
|
37
|
+
def get_dimensions(
|
38
|
+
self,
|
39
|
+
*,
|
40
|
+
modality: typing.Optional[Modality] = OMIT,
|
41
|
+
model: typing.Optional[str] = OMIT,
|
42
|
+
request_options: typing.Optional[RequestOptions] = None,
|
43
|
+
) -> ConfigsResponse:
|
44
|
+
"""
|
45
|
+
Parameters:
|
46
|
+
- modality: typing.Optional[Modality].
|
47
|
+
|
48
|
+
- model: typing.Optional[str].
|
49
|
+
|
50
|
+
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
51
|
+
---
|
52
|
+
from mixpeek.client import Mixpeek
|
53
|
+
|
54
|
+
client = Mixpeek(
|
55
|
+
authorization="YOUR_AUTHORIZATION",
|
56
|
+
index_id="YOUR_INDEX_ID",
|
57
|
+
api_key="YOUR_API_KEY",
|
58
|
+
)
|
59
|
+
client.embed.get_dimensions()
|
60
|
+
"""
|
61
|
+
_request: typing.Dict[str, typing.Any] = {}
|
62
|
+
if modality is not OMIT:
|
63
|
+
_request["modality"] = modality
|
64
|
+
if model is not OMIT:
|
65
|
+
_request["model"] = model
|
66
|
+
_response = self._client_wrapper.httpx_client.request(
|
67
|
+
"POST",
|
68
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "embed/config"),
|
69
|
+
params=jsonable_encoder(
|
70
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
71
|
+
),
|
72
|
+
json=jsonable_encoder(_request)
|
73
|
+
if request_options is None or request_options.get("additional_body_parameters") is None
|
74
|
+
else {
|
75
|
+
**jsonable_encoder(_request),
|
76
|
+
**(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
|
77
|
+
},
|
78
|
+
headers=jsonable_encoder(
|
79
|
+
remove_none_from_dict(
|
80
|
+
{
|
81
|
+
**self._client_wrapper.get_headers(),
|
82
|
+
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
83
|
+
}
|
84
|
+
)
|
85
|
+
),
|
86
|
+
timeout=request_options.get("timeout_in_seconds")
|
87
|
+
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
88
|
+
else self._client_wrapper.get_timeout(),
|
89
|
+
retries=0,
|
90
|
+
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
91
|
+
)
|
92
|
+
if 200 <= _response.status_code < 300:
|
93
|
+
return pydantic.parse_obj_as(ConfigsResponse, _response.json()) # type: ignore
|
94
|
+
if _response.status_code == 400:
|
95
|
+
raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
96
|
+
if _response.status_code == 401:
|
97
|
+
raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
98
|
+
if _response.status_code == 403:
|
99
|
+
raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
100
|
+
if _response.status_code == 404:
|
101
|
+
raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
102
|
+
if _response.status_code == 422:
|
103
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
104
|
+
if _response.status_code == 500:
|
105
|
+
raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
106
|
+
try:
|
107
|
+
_response_json = _response.json()
|
108
|
+
except JSONDecodeError:
|
109
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
110
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
111
|
+
|
112
|
+
def input_embed_post(
|
113
|
+
self,
|
114
|
+
*,
|
115
|
+
input: str,
|
116
|
+
modality: typing.Optional[Modality] = OMIT,
|
117
|
+
model: typing.Optional[str] = OMIT,
|
118
|
+
request_options: typing.Optional[RequestOptions] = None,
|
119
|
+
) -> EmbeddingResponse:
|
120
|
+
"""
|
121
|
+
Parameters:
|
122
|
+
- input: str.
|
123
|
+
|
124
|
+
- modality: typing.Optional[Modality].
|
125
|
+
|
126
|
+
- model: typing.Optional[str].
|
127
|
+
|
128
|
+
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
129
|
+
---
|
130
|
+
from mixpeek.client import Mixpeek
|
131
|
+
|
132
|
+
client = Mixpeek(
|
133
|
+
authorization="YOUR_AUTHORIZATION",
|
134
|
+
index_id="YOUR_INDEX_ID",
|
135
|
+
api_key="YOUR_API_KEY",
|
136
|
+
)
|
137
|
+
client.embed.input_embed_post(
|
138
|
+
input="input",
|
139
|
+
)
|
140
|
+
"""
|
141
|
+
_request: typing.Dict[str, typing.Any] = {"input": input}
|
142
|
+
if modality is not OMIT:
|
143
|
+
_request["modality"] = modality
|
144
|
+
if model is not OMIT:
|
145
|
+
_request["model"] = model
|
146
|
+
_response = self._client_wrapper.httpx_client.request(
|
147
|
+
"POST",
|
148
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "embed"),
|
149
|
+
params=jsonable_encoder(
|
150
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
151
|
+
),
|
152
|
+
json=jsonable_encoder(_request)
|
153
|
+
if request_options is None or request_options.get("additional_body_parameters") is None
|
154
|
+
else {
|
155
|
+
**jsonable_encoder(_request),
|
156
|
+
**(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
|
157
|
+
},
|
158
|
+
headers=jsonable_encoder(
|
159
|
+
remove_none_from_dict(
|
160
|
+
{
|
161
|
+
**self._client_wrapper.get_headers(),
|
162
|
+
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
163
|
+
}
|
164
|
+
)
|
165
|
+
),
|
166
|
+
timeout=request_options.get("timeout_in_seconds")
|
167
|
+
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
168
|
+
else self._client_wrapper.get_timeout(),
|
169
|
+
retries=0,
|
170
|
+
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
171
|
+
)
|
172
|
+
if 200 <= _response.status_code < 300:
|
173
|
+
return pydantic.parse_obj_as(EmbeddingResponse, _response.json()) # type: ignore
|
174
|
+
if _response.status_code == 400:
|
175
|
+
raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
176
|
+
if _response.status_code == 401:
|
177
|
+
raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
178
|
+
if _response.status_code == 403:
|
179
|
+
raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
180
|
+
if _response.status_code == 404:
|
181
|
+
raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
182
|
+
if _response.status_code == 422:
|
183
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
184
|
+
if _response.status_code == 500:
|
185
|
+
raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
186
|
+
try:
|
187
|
+
_response_json = _response.json()
|
188
|
+
except JSONDecodeError:
|
189
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
190
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
191
|
+
|
192
|
+
|
193
|
+
class AsyncEmbedClient:
|
194
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
195
|
+
self._client_wrapper = client_wrapper
|
196
|
+
|
197
|
+
async def get_dimensions(
|
198
|
+
self,
|
199
|
+
*,
|
200
|
+
modality: typing.Optional[Modality] = OMIT,
|
201
|
+
model: typing.Optional[str] = OMIT,
|
202
|
+
request_options: typing.Optional[RequestOptions] = None,
|
203
|
+
) -> ConfigsResponse:
|
204
|
+
"""
|
205
|
+
Parameters:
|
206
|
+
- modality: typing.Optional[Modality].
|
207
|
+
|
208
|
+
- model: typing.Optional[str].
|
209
|
+
|
210
|
+
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
211
|
+
---
|
212
|
+
from mixpeek.client import AsyncMixpeek
|
213
|
+
|
214
|
+
client = AsyncMixpeek(
|
215
|
+
authorization="YOUR_AUTHORIZATION",
|
216
|
+
index_id="YOUR_INDEX_ID",
|
217
|
+
api_key="YOUR_API_KEY",
|
218
|
+
)
|
219
|
+
await client.embed.get_dimensions()
|
220
|
+
"""
|
221
|
+
_request: typing.Dict[str, typing.Any] = {}
|
222
|
+
if modality is not OMIT:
|
223
|
+
_request["modality"] = modality
|
224
|
+
if model is not OMIT:
|
225
|
+
_request["model"] = model
|
226
|
+
_response = await self._client_wrapper.httpx_client.request(
|
227
|
+
"POST",
|
228
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "embed/config"),
|
229
|
+
params=jsonable_encoder(
|
230
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
231
|
+
),
|
232
|
+
json=jsonable_encoder(_request)
|
233
|
+
if request_options is None or request_options.get("additional_body_parameters") is None
|
234
|
+
else {
|
235
|
+
**jsonable_encoder(_request),
|
236
|
+
**(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
|
237
|
+
},
|
238
|
+
headers=jsonable_encoder(
|
239
|
+
remove_none_from_dict(
|
240
|
+
{
|
241
|
+
**self._client_wrapper.get_headers(),
|
242
|
+
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
243
|
+
}
|
244
|
+
)
|
245
|
+
),
|
246
|
+
timeout=request_options.get("timeout_in_seconds")
|
247
|
+
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
248
|
+
else self._client_wrapper.get_timeout(),
|
249
|
+
retries=0,
|
250
|
+
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
251
|
+
)
|
252
|
+
if 200 <= _response.status_code < 300:
|
253
|
+
return pydantic.parse_obj_as(ConfigsResponse, _response.json()) # type: ignore
|
254
|
+
if _response.status_code == 400:
|
255
|
+
raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
256
|
+
if _response.status_code == 401:
|
257
|
+
raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
258
|
+
if _response.status_code == 403:
|
259
|
+
raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
260
|
+
if _response.status_code == 404:
|
261
|
+
raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
262
|
+
if _response.status_code == 422:
|
263
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
264
|
+
if _response.status_code == 500:
|
265
|
+
raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
266
|
+
try:
|
267
|
+
_response_json = _response.json()
|
268
|
+
except JSONDecodeError:
|
269
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
270
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
271
|
+
|
272
|
+
async def input_embed_post(
|
273
|
+
self,
|
274
|
+
*,
|
275
|
+
input: str,
|
276
|
+
modality: typing.Optional[Modality] = OMIT,
|
277
|
+
model: typing.Optional[str] = OMIT,
|
278
|
+
request_options: typing.Optional[RequestOptions] = None,
|
279
|
+
) -> EmbeddingResponse:
|
280
|
+
"""
|
281
|
+
Parameters:
|
282
|
+
- input: str.
|
283
|
+
|
284
|
+
- modality: typing.Optional[Modality].
|
285
|
+
|
286
|
+
- model: typing.Optional[str].
|
287
|
+
|
288
|
+
- request_options: typing.Optional[RequestOptions]. Request-specific configuration.
|
289
|
+
---
|
290
|
+
from mixpeek.client import AsyncMixpeek
|
291
|
+
|
292
|
+
client = AsyncMixpeek(
|
293
|
+
authorization="YOUR_AUTHORIZATION",
|
294
|
+
index_id="YOUR_INDEX_ID",
|
295
|
+
api_key="YOUR_API_KEY",
|
296
|
+
)
|
297
|
+
await client.embed.input_embed_post(
|
298
|
+
input="input",
|
299
|
+
)
|
300
|
+
"""
|
301
|
+
_request: typing.Dict[str, typing.Any] = {"input": input}
|
302
|
+
if modality is not OMIT:
|
303
|
+
_request["modality"] = modality
|
304
|
+
if model is not OMIT:
|
305
|
+
_request["model"] = model
|
306
|
+
_response = await self._client_wrapper.httpx_client.request(
|
307
|
+
"POST",
|
308
|
+
urllib.parse.urljoin(f"{self._client_wrapper.get_base_url()}/", "embed"),
|
309
|
+
params=jsonable_encoder(
|
310
|
+
request_options.get("additional_query_parameters") if request_options is not None else None
|
311
|
+
),
|
312
|
+
json=jsonable_encoder(_request)
|
313
|
+
if request_options is None or request_options.get("additional_body_parameters") is None
|
314
|
+
else {
|
315
|
+
**jsonable_encoder(_request),
|
316
|
+
**(jsonable_encoder(remove_none_from_dict(request_options.get("additional_body_parameters", {})))),
|
317
|
+
},
|
318
|
+
headers=jsonable_encoder(
|
319
|
+
remove_none_from_dict(
|
320
|
+
{
|
321
|
+
**self._client_wrapper.get_headers(),
|
322
|
+
**(request_options.get("additional_headers", {}) if request_options is not None else {}),
|
323
|
+
}
|
324
|
+
)
|
325
|
+
),
|
326
|
+
timeout=request_options.get("timeout_in_seconds")
|
327
|
+
if request_options is not None and request_options.get("timeout_in_seconds") is not None
|
328
|
+
else self._client_wrapper.get_timeout(),
|
329
|
+
retries=0,
|
330
|
+
max_retries=request_options.get("max_retries") if request_options is not None else 0, # type: ignore
|
331
|
+
)
|
332
|
+
if 200 <= _response.status_code < 300:
|
333
|
+
return pydantic.parse_obj_as(EmbeddingResponse, _response.json()) # type: ignore
|
334
|
+
if _response.status_code == 400:
|
335
|
+
raise BadRequestError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
336
|
+
if _response.status_code == 401:
|
337
|
+
raise UnauthorizedError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
338
|
+
if _response.status_code == 403:
|
339
|
+
raise ForbiddenError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
340
|
+
if _response.status_code == 404:
|
341
|
+
raise NotFoundError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
342
|
+
if _response.status_code == 422:
|
343
|
+
raise UnprocessableEntityError(pydantic.parse_obj_as(HttpValidationError, _response.json())) # type: ignore
|
344
|
+
if _response.status_code == 500:
|
345
|
+
raise InternalServerError(pydantic.parse_obj_as(ErrorResponse, _response.json())) # type: ignore
|
346
|
+
try:
|
347
|
+
_response_json = _response.json()
|
348
|
+
except JSONDecodeError:
|
349
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
350
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
mixpeek/environment.py
ADDED