@scaleway/sdk-inference 1.0.1

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 (37) hide show
  1. package/LICENSE +191 -0
  2. package/dist/index.gen.cjs +6 -0
  3. package/dist/index.gen.d.ts +6 -0
  4. package/dist/index.gen.js +6 -0
  5. package/dist/v1/api.gen.cjs +271 -0
  6. package/dist/v1/api.gen.d.ts +137 -0
  7. package/dist/v1/api.gen.js +271 -0
  8. package/dist/v1/content.gen.cjs +13 -0
  9. package/dist/v1/content.gen.d.ts +5 -0
  10. package/dist/v1/content.gen.js +13 -0
  11. package/dist/v1/index.gen.cjs +22 -0
  12. package/dist/v1/index.gen.d.ts +5 -0
  13. package/dist/v1/index.gen.js +22 -0
  14. package/dist/v1/marshalling.gen.cjs +258 -0
  15. package/dist/v1/marshalling.gen.d.ts +14 -0
  16. package/dist/v1/marshalling.gen.js +258 -0
  17. package/dist/v1/types.gen.d.ts +577 -0
  18. package/dist/v1/validation-rules.gen.cjs +65 -0
  19. package/dist/v1/validation-rules.gen.d.ts +57 -0
  20. package/dist/v1/validation-rules.gen.js +65 -0
  21. package/dist/v1beta1/api.gen.cjs +301 -0
  22. package/dist/v1beta1/api.gen.d.ts +148 -0
  23. package/dist/v1beta1/api.gen.js +301 -0
  24. package/dist/v1beta1/content.gen.cjs +8 -0
  25. package/dist/v1beta1/content.gen.d.ts +3 -0
  26. package/dist/v1beta1/content.gen.js +8 -0
  27. package/dist/v1beta1/index.gen.cjs +25 -0
  28. package/dist/v1beta1/index.gen.d.ts +5 -0
  29. package/dist/v1beta1/index.gen.js +25 -0
  30. package/dist/v1beta1/marshalling.gen.cjs +271 -0
  31. package/dist/v1beta1/marshalling.gen.d.ts +18 -0
  32. package/dist/v1beta1/marshalling.gen.js +271 -0
  33. package/dist/v1beta1/types.gen.d.ts +622 -0
  34. package/dist/v1beta1/validation-rules.gen.cjs +56 -0
  35. package/dist/v1beta1/validation-rules.gen.d.ts +50 -0
  36. package/dist/v1beta1/validation-rules.gen.js +56 -0
  37. package/package.json +51 -0
@@ -0,0 +1,271 @@
1
+ import { API as API$1, urlParams, validatePathParam, enrichForPagination, waitForResource } from "@scaleway/sdk-client";
2
+ import { DEPLOYMENT_TRANSIENT_STATUSES, MODEL_TRANSIENT_STATUSES } from "./content.gen.js";
3
+ import { unmarshalListDeploymentsResponse, unmarshalDeployment, marshalCreateDeploymentRequest, marshalUpdateDeploymentRequest, marshalCreateEndpointRequest, unmarshalEndpoint, marshalUpdateEndpointRequest, unmarshalListModelsResponse, unmarshalModel, marshalCreateModelRequest, unmarshalListNodeTypesResponse } from "./marshalling.gen.js";
4
+ const jsonContentHeaders = {
5
+ "Content-Type": "application/json; charset=utf-8"
6
+ };
7
+ class API extends API$1 {
8
+ /** Lists the available regions of the API. */
9
+ static LOCALITIES = ["fr-par"];
10
+ pageOfListDeployments = (request = {}) => this.client.fetch(
11
+ {
12
+ method: "GET",
13
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments`,
14
+ urlParams: urlParams(
15
+ ["name", request.name],
16
+ ["order_by", request.orderBy],
17
+ ["organization_id", request.organizationId],
18
+ ["page", request.page],
19
+ [
20
+ "page_size",
21
+ request.pageSize ?? this.client.settings.defaultPageSize
22
+ ],
23
+ ["project_id", request.projectId],
24
+ ["tags", request.tags]
25
+ )
26
+ },
27
+ unmarshalListDeploymentsResponse
28
+ );
29
+ /**
30
+ * List inference deployments. List all your inference deployments.
31
+ *
32
+ * @param request - The request {@link ListDeploymentsRequest}
33
+ * @returns A Promise of ListDeploymentsResponse
34
+ */
35
+ listDeployments = (request = {}) => enrichForPagination("deployments", this.pageOfListDeployments, request);
36
+ /**
37
+ * Get a deployment. Get the deployment for the given ID.
38
+ *
39
+ * @param request - The request {@link GetDeploymentRequest}
40
+ * @returns A Promise of Deployment
41
+ */
42
+ getDeployment = (request) => this.client.fetch(
43
+ {
44
+ method: "GET",
45
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}`
46
+ },
47
+ unmarshalDeployment
48
+ );
49
+ /**
50
+ * Waits for {@link Deployment} to be in a final state.
51
+ *
52
+ * @param request - The request {@link GetDeploymentRequest}
53
+ * @param options - The waiting options
54
+ * @returns A Promise of Deployment
55
+ */
56
+ waitForDeployment = (request, options) => waitForResource(
57
+ options?.stop ?? ((res) => Promise.resolve(
58
+ !DEPLOYMENT_TRANSIENT_STATUSES.includes(res.status)
59
+ )),
60
+ this.getDeployment,
61
+ request,
62
+ options
63
+ );
64
+ /**
65
+ * Create a deployment. Create a new inference deployment related to a specific model.
66
+ *
67
+ * @param request - The request {@link CreateDeploymentRequest}
68
+ * @returns A Promise of Deployment
69
+ */
70
+ createDeployment = (request) => this.client.fetch(
71
+ {
72
+ body: JSON.stringify(
73
+ marshalCreateDeploymentRequest(request, this.client.settings)
74
+ ),
75
+ headers: jsonContentHeaders,
76
+ method: "POST",
77
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments`
78
+ },
79
+ unmarshalDeployment
80
+ );
81
+ /**
82
+ * Update a deployment. Update an existing inference deployment.
83
+ *
84
+ * @param request - The request {@link UpdateDeploymentRequest}
85
+ * @returns A Promise of Deployment
86
+ */
87
+ updateDeployment = (request) => this.client.fetch(
88
+ {
89
+ body: JSON.stringify(
90
+ marshalUpdateDeploymentRequest(request, this.client.settings)
91
+ ),
92
+ headers: jsonContentHeaders,
93
+ method: "PATCH",
94
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}`
95
+ },
96
+ unmarshalDeployment
97
+ );
98
+ /**
99
+ * Delete a deployment. Delete an existing inference deployment.
100
+ *
101
+ * @param request - The request {@link DeleteDeploymentRequest}
102
+ * @returns A Promise of Deployment
103
+ */
104
+ deleteDeployment = (request) => this.client.fetch(
105
+ {
106
+ method: "DELETE",
107
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}`
108
+ },
109
+ unmarshalDeployment
110
+ );
111
+ /**
112
+ * Get the CA certificate. Get the CA certificate used for the deployment of private endpoints.
113
+ The CA certificate will be returned as a PEM file.
114
+ *
115
+ * @param request - The request {@link GetDeploymentCertificateRequest}
116
+ * @returns A Promise of Blob
117
+ */
118
+ getDeploymentCertificate = (request) => this.client.fetch({
119
+ method: "GET",
120
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/deployments/${validatePathParam("deploymentId", request.deploymentId)}/certificate`,
121
+ urlParams: urlParams(["dl", 1]),
122
+ responseType: "blob"
123
+ });
124
+ /**
125
+ * Create an endpoint. Create a new Endpoint related to a specific deployment.
126
+ *
127
+ * @param request - The request {@link CreateEndpointRequest}
128
+ * @returns A Promise of Endpoint
129
+ */
130
+ createEndpoint = (request) => this.client.fetch(
131
+ {
132
+ body: JSON.stringify(
133
+ marshalCreateEndpointRequest(request, this.client.settings)
134
+ ),
135
+ headers: jsonContentHeaders,
136
+ method: "POST",
137
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/endpoints`
138
+ },
139
+ unmarshalEndpoint
140
+ );
141
+ /**
142
+ * Update an endpoint. Update an existing Endpoint.
143
+ *
144
+ * @param request - The request {@link UpdateEndpointRequest}
145
+ * @returns A Promise of Endpoint
146
+ */
147
+ updateEndpoint = (request) => this.client.fetch(
148
+ {
149
+ body: JSON.stringify(
150
+ marshalUpdateEndpointRequest(request, this.client.settings)
151
+ ),
152
+ headers: jsonContentHeaders,
153
+ method: "PATCH",
154
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/endpoints/${validatePathParam("endpointId", request.endpointId)}`
155
+ },
156
+ unmarshalEndpoint
157
+ );
158
+ /**
159
+ * Delete an endpoint. Delete an existing Endpoint.
160
+ *
161
+ * @param request - The request {@link DeleteEndpointRequest}
162
+ */
163
+ deleteEndpoint = (request) => this.client.fetch({
164
+ method: "DELETE",
165
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/endpoints/${validatePathParam("endpointId", request.endpointId)}`
166
+ });
167
+ pageOfListModels = (request = {}) => this.client.fetch(
168
+ {
169
+ method: "GET",
170
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/models`,
171
+ urlParams: urlParams(
172
+ ["name", request.name],
173
+ ["order_by", request.orderBy],
174
+ ["page", request.page],
175
+ [
176
+ "page_size",
177
+ request.pageSize ?? this.client.settings.defaultPageSize
178
+ ],
179
+ ["project_id", request.projectId],
180
+ ["tags", request.tags]
181
+ )
182
+ },
183
+ unmarshalListModelsResponse
184
+ );
185
+ /**
186
+ * List models. List all available models.
187
+ *
188
+ * @param request - The request {@link ListModelsRequest}
189
+ * @returns A Promise of ListModelsResponse
190
+ */
191
+ listModels = (request = {}) => enrichForPagination("models", this.pageOfListModels, request);
192
+ /**
193
+ * Get a model. Get the model for the given ID.
194
+ *
195
+ * @param request - The request {@link GetModelRequest}
196
+ * @returns A Promise of Model
197
+ */
198
+ getModel = (request) => this.client.fetch(
199
+ {
200
+ method: "GET",
201
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/models/${validatePathParam("modelId", request.modelId)}`
202
+ },
203
+ unmarshalModel
204
+ );
205
+ /**
206
+ * Waits for {@link Model} to be in a final state.
207
+ *
208
+ * @param request - The request {@link GetModelRequest}
209
+ * @param options - The waiting options
210
+ * @returns A Promise of Model
211
+ */
212
+ waitForModel = (request, options) => waitForResource(
213
+ options?.stop ?? ((res) => Promise.resolve(
214
+ !MODEL_TRANSIENT_STATUSES.includes(res.status)
215
+ )),
216
+ this.getModel,
217
+ request,
218
+ options
219
+ );
220
+ /**
221
+ * Import a model. Import a new model to your model library.
222
+ *
223
+ * @param request - The request {@link CreateModelRequest}
224
+ * @returns A Promise of Model
225
+ */
226
+ createModel = (request) => this.client.fetch(
227
+ {
228
+ body: JSON.stringify(
229
+ marshalCreateModelRequest(request, this.client.settings)
230
+ ),
231
+ headers: jsonContentHeaders,
232
+ method: "POST",
233
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/models`
234
+ },
235
+ unmarshalModel
236
+ );
237
+ /**
238
+ * Delete a model. Delete an existing model from your model library.
239
+ *
240
+ * @param request - The request {@link DeleteModelRequest}
241
+ */
242
+ deleteModel = (request) => this.client.fetch({
243
+ method: "DELETE",
244
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/models/${validatePathParam("modelId", request.modelId)}`
245
+ });
246
+ pageOfListNodeTypes = (request) => this.client.fetch(
247
+ {
248
+ method: "GET",
249
+ path: `/inference/v1/regions/${validatePathParam("region", request.region ?? this.client.settings.defaultRegion)}/node-types`,
250
+ urlParams: urlParams(
251
+ ["include_disabled_types", request.includeDisabledTypes],
252
+ ["page", request.page],
253
+ [
254
+ "page_size",
255
+ request.pageSize ?? this.client.settings.defaultPageSize
256
+ ]
257
+ )
258
+ },
259
+ unmarshalListNodeTypesResponse
260
+ );
261
+ /**
262
+ * List available node types. List all available node types. By default, the node types returned in the list are ordered by creation date in ascending order, though this can be modified via the `order_by` field.
263
+ *
264
+ * @param request - The request {@link ListNodeTypesRequest}
265
+ * @returns A Promise of ListNodeTypesResponse
266
+ */
267
+ listNodeTypes = (request) => enrichForPagination("nodeTypes", this.pageOfListNodeTypes, request);
268
+ }
269
+ export {
270
+ API
271
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const DEPLOYMENT_TRANSIENT_STATUSES = [
4
+ "creating",
5
+ "deploying",
6
+ "deleting"
7
+ ];
8
+ const MODEL_TRANSIENT_STATUSES = [
9
+ "preparing",
10
+ "downloading"
11
+ ];
12
+ exports.DEPLOYMENT_TRANSIENT_STATUSES = DEPLOYMENT_TRANSIENT_STATUSES;
13
+ exports.MODEL_TRANSIENT_STATUSES = MODEL_TRANSIENT_STATUSES;
@@ -0,0 +1,5 @@
1
+ import type { DeploymentStatus, ModelStatus } from './types.gen';
2
+ /** Lists transient statutes of the enum {@link DeploymentStatus}. */
3
+ export declare const DEPLOYMENT_TRANSIENT_STATUSES: DeploymentStatus[];
4
+ /** Lists transient statutes of the enum {@link ModelStatus}. */
5
+ export declare const MODEL_TRANSIENT_STATUSES: ModelStatus[];
@@ -0,0 +1,13 @@
1
+ const DEPLOYMENT_TRANSIENT_STATUSES = [
2
+ "creating",
3
+ "deploying",
4
+ "deleting"
5
+ ];
6
+ const MODEL_TRANSIENT_STATUSES = [
7
+ "preparing",
8
+ "downloading"
9
+ ];
10
+ export {
11
+ DEPLOYMENT_TRANSIENT_STATUSES,
12
+ MODEL_TRANSIENT_STATUSES
13
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const api_gen = require("./api.gen.cjs");
4
+ const content_gen = require("./content.gen.cjs");
5
+ const marshalling_gen = require("./marshalling.gen.cjs");
6
+ const validationRules_gen = require("./validation-rules.gen.cjs");
7
+ exports.API = api_gen.API;
8
+ exports.DEPLOYMENT_TRANSIENT_STATUSES = content_gen.DEPLOYMENT_TRANSIENT_STATUSES;
9
+ exports.MODEL_TRANSIENT_STATUSES = content_gen.MODEL_TRANSIENT_STATUSES;
10
+ exports.marshalCreateDeploymentRequest = marshalling_gen.marshalCreateDeploymentRequest;
11
+ exports.marshalCreateEndpointRequest = marshalling_gen.marshalCreateEndpointRequest;
12
+ exports.marshalCreateModelRequest = marshalling_gen.marshalCreateModelRequest;
13
+ exports.marshalUpdateDeploymentRequest = marshalling_gen.marshalUpdateDeploymentRequest;
14
+ exports.marshalUpdateEndpointRequest = marshalling_gen.marshalUpdateEndpointRequest;
15
+ exports.unmarshalDeployment = marshalling_gen.unmarshalDeployment;
16
+ exports.unmarshalEndpoint = marshalling_gen.unmarshalEndpoint;
17
+ exports.unmarshalListDeploymentsResponse = marshalling_gen.unmarshalListDeploymentsResponse;
18
+ exports.unmarshalListModelsResponse = marshalling_gen.unmarshalListModelsResponse;
19
+ exports.unmarshalListNodeTypesResponse = marshalling_gen.unmarshalListNodeTypesResponse;
20
+ exports.unmarshalModel = marshalling_gen.unmarshalModel;
21
+ exports.unmarshalModelSupportInfo = marshalling_gen.unmarshalModelSupportInfo;
22
+ exports.ValidationRules = validationRules_gen;
@@ -0,0 +1,5 @@
1
+ export { API } from './api.gen';
2
+ export * from './content.gen';
3
+ export * from './marshalling.gen';
4
+ export type { CreateDeploymentRequest, CreateEndpointRequest, CreateModelRequest, DeleteDeploymentRequest, DeleteEndpointRequest, DeleteModelRequest, Deployment, DeploymentQuantization, DeploymentStatus, Endpoint, EndpointPrivateNetworkDetails, EndpointPublicNetworkDetails, EndpointSpec, GetDeploymentCertificateRequest, GetDeploymentRequest, GetModelRequest, ListDeploymentsRequest, ListDeploymentsRequestOrderBy, ListDeploymentsResponse, ListModelsRequest, ListModelsRequestOrderBy, ListModelsResponse, ListNodeTypesRequest, ListNodeTypesResponse, Model, ModelSource, ModelStatus, ModelSupportInfo, ModelSupportedNode, ModelSupportedQuantization, NodeType, NodeTypeStock, UpdateDeploymentRequest, UpdateEndpointRequest, } from './types.gen';
5
+ export * as ValidationRules from './validation-rules.gen';
@@ -0,0 +1,22 @@
1
+ import { API } from "./api.gen.js";
2
+ import { DEPLOYMENT_TRANSIENT_STATUSES, MODEL_TRANSIENT_STATUSES } from "./content.gen.js";
3
+ import { marshalCreateDeploymentRequest, marshalCreateEndpointRequest, marshalCreateModelRequest, marshalUpdateDeploymentRequest, marshalUpdateEndpointRequest, unmarshalDeployment, unmarshalEndpoint, unmarshalListDeploymentsResponse, unmarshalListModelsResponse, unmarshalListNodeTypesResponse, unmarshalModel, unmarshalModelSupportInfo } from "./marshalling.gen.js";
4
+ import * as validationRules_gen from "./validation-rules.gen.js";
5
+ export {
6
+ API,
7
+ DEPLOYMENT_TRANSIENT_STATUSES,
8
+ MODEL_TRANSIENT_STATUSES,
9
+ validationRules_gen as ValidationRules,
10
+ marshalCreateDeploymentRequest,
11
+ marshalCreateEndpointRequest,
12
+ marshalCreateModelRequest,
13
+ marshalUpdateDeploymentRequest,
14
+ marshalUpdateEndpointRequest,
15
+ unmarshalDeployment,
16
+ unmarshalEndpoint,
17
+ unmarshalListDeploymentsResponse,
18
+ unmarshalListModelsResponse,
19
+ unmarshalListNodeTypesResponse,
20
+ unmarshalModel,
21
+ unmarshalModelSupportInfo
22
+ };
@@ -0,0 +1,258 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const randomName = require("@scaleway/random-name");
4
+ const sdkClient = require("@scaleway/sdk-client");
5
+ const unmarshalEndpointPrivateNetworkDetails = (data) => {
6
+ if (!sdkClient.isJSONObject(data)) {
7
+ throw new TypeError(
8
+ `Unmarshalling the type 'EndpointPrivateNetworkDetails' failed as data isn't a dictionary.`
9
+ );
10
+ }
11
+ return {
12
+ privateNetworkId: data.private_network_id
13
+ };
14
+ };
15
+ const unmarshalEndpointPublicNetworkDetails = (data) => {
16
+ if (!sdkClient.isJSONObject(data)) {
17
+ throw new TypeError(
18
+ `Unmarshalling the type 'EndpointPublicNetworkDetails' failed as data isn't a dictionary.`
19
+ );
20
+ }
21
+ return {};
22
+ };
23
+ const unmarshalEndpoint = (data) => {
24
+ if (!sdkClient.isJSONObject(data)) {
25
+ throw new TypeError(
26
+ `Unmarshalling the type 'Endpoint' failed as data isn't a dictionary.`
27
+ );
28
+ }
29
+ return {
30
+ disableAuth: data.disable_auth,
31
+ id: data.id,
32
+ privateNetwork: data.private_network ? unmarshalEndpointPrivateNetworkDetails(data.private_network) : void 0,
33
+ publicNetwork: data.public_network ? unmarshalEndpointPublicNetworkDetails(data.public_network) : void 0,
34
+ url: data.url
35
+ };
36
+ };
37
+ const unmarshalModelSupportedQuantization = (data) => {
38
+ if (!sdkClient.isJSONObject(data)) {
39
+ throw new TypeError(
40
+ `Unmarshalling the type 'ModelSupportedQuantization' failed as data isn't a dictionary.`
41
+ );
42
+ }
43
+ return {
44
+ allowed: data.allowed,
45
+ maxContextSize: data.max_context_size,
46
+ quantizationBits: data.quantization_bits
47
+ };
48
+ };
49
+ const unmarshalModelSupportedNode = (data) => {
50
+ if (!sdkClient.isJSONObject(data)) {
51
+ throw new TypeError(
52
+ `Unmarshalling the type 'ModelSupportedNode' failed as data isn't a dictionary.`
53
+ );
54
+ }
55
+ return {
56
+ nodeTypeName: data.node_type_name,
57
+ quantizations: sdkClient.unmarshalArrayOfObject(
58
+ data.quantizations,
59
+ unmarshalModelSupportedQuantization
60
+ )
61
+ };
62
+ };
63
+ const unmarshalModelSupportInfo = (data) => {
64
+ if (!sdkClient.isJSONObject(data)) {
65
+ throw new TypeError(
66
+ `Unmarshalling the type 'ModelSupportInfo' failed as data isn't a dictionary.`
67
+ );
68
+ }
69
+ return {
70
+ nodes: sdkClient.unmarshalArrayOfObject(data.nodes, unmarshalModelSupportedNode)
71
+ };
72
+ };
73
+ const unmarshalDeploymentQuantization = (data) => {
74
+ if (!sdkClient.isJSONObject(data)) {
75
+ throw new TypeError(
76
+ `Unmarshalling the type 'DeploymentQuantization' failed as data isn't a dictionary.`
77
+ );
78
+ }
79
+ return {
80
+ bits: data.bits
81
+ };
82
+ };
83
+ const unmarshalDeployment = (data) => {
84
+ if (!sdkClient.isJSONObject(data)) {
85
+ throw new TypeError(
86
+ `Unmarshalling the type 'Deployment' failed as data isn't a dictionary.`
87
+ );
88
+ }
89
+ return {
90
+ createdAt: sdkClient.unmarshalDate(data.created_at),
91
+ endpoints: sdkClient.unmarshalArrayOfObject(data.endpoints, unmarshalEndpoint),
92
+ errorMessage: data.error_message,
93
+ id: data.id,
94
+ maxSize: data.max_size,
95
+ minSize: data.min_size,
96
+ modelId: data.model_id,
97
+ modelName: data.model_name,
98
+ name: data.name,
99
+ nodeTypeName: data.node_type_name,
100
+ projectId: data.project_id,
101
+ quantization: data.quantization ? unmarshalDeploymentQuantization(data.quantization) : void 0,
102
+ region: data.region,
103
+ size: data.size,
104
+ status: data.status,
105
+ tags: data.tags,
106
+ updatedAt: sdkClient.unmarshalDate(data.updated_at)
107
+ };
108
+ };
109
+ const unmarshalModel = (data) => {
110
+ if (!sdkClient.isJSONObject(data)) {
111
+ throw new TypeError(
112
+ `Unmarshalling the type 'Model' failed as data isn't a dictionary.`
113
+ );
114
+ }
115
+ return {
116
+ createdAt: sdkClient.unmarshalDate(data.created_at),
117
+ description: data.description,
118
+ errorMessage: data.error_message,
119
+ hasEula: data.has_eula,
120
+ id: data.id,
121
+ name: data.name,
122
+ nodesSupport: sdkClient.unmarshalArrayOfObject(
123
+ data.nodes_support,
124
+ unmarshalModelSupportInfo
125
+ ),
126
+ parameterSizeBits: data.parameter_size_bits,
127
+ projectId: data.project_id,
128
+ region: data.region,
129
+ sizeBytes: data.size_bytes,
130
+ status: data.status,
131
+ tags: data.tags,
132
+ updatedAt: sdkClient.unmarshalDate(data.updated_at)
133
+ };
134
+ };
135
+ const unmarshalListDeploymentsResponse = (data) => {
136
+ if (!sdkClient.isJSONObject(data)) {
137
+ throw new TypeError(
138
+ `Unmarshalling the type 'ListDeploymentsResponse' failed as data isn't a dictionary.`
139
+ );
140
+ }
141
+ return {
142
+ deployments: sdkClient.unmarshalArrayOfObject(data.deployments, unmarshalDeployment),
143
+ totalCount: data.total_count
144
+ };
145
+ };
146
+ const unmarshalListModelsResponse = (data) => {
147
+ if (!sdkClient.isJSONObject(data)) {
148
+ throw new TypeError(
149
+ `Unmarshalling the type 'ListModelsResponse' failed as data isn't a dictionary.`
150
+ );
151
+ }
152
+ return {
153
+ models: sdkClient.unmarshalArrayOfObject(data.models, unmarshalModel),
154
+ totalCount: data.total_count
155
+ };
156
+ };
157
+ const unmarshalNodeType = (data) => {
158
+ if (!sdkClient.isJSONObject(data)) {
159
+ throw new TypeError(
160
+ `Unmarshalling the type 'NodeType' failed as data isn't a dictionary.`
161
+ );
162
+ }
163
+ return {
164
+ beta: data.beta,
165
+ createdAt: sdkClient.unmarshalDate(data.created_at),
166
+ description: data.description,
167
+ disabled: data.disabled,
168
+ gpus: data.gpus,
169
+ memory: data.memory,
170
+ name: data.name,
171
+ region: data.region,
172
+ stockStatus: data.stock_status,
173
+ updatedAt: sdkClient.unmarshalDate(data.updated_at),
174
+ vcpus: data.vcpus,
175
+ vram: data.vram
176
+ };
177
+ };
178
+ const unmarshalListNodeTypesResponse = (data) => {
179
+ if (!sdkClient.isJSONObject(data)) {
180
+ throw new TypeError(
181
+ `Unmarshalling the type 'ListNodeTypesResponse' failed as data isn't a dictionary.`
182
+ );
183
+ }
184
+ return {
185
+ nodeTypes: sdkClient.unmarshalArrayOfObject(data.node_types, unmarshalNodeType),
186
+ totalCount: data.total_count
187
+ };
188
+ };
189
+ const marshalEndpointPrivateNetworkDetails = (request, defaults) => ({
190
+ private_network_id: request.privateNetworkId
191
+ });
192
+ const marshalEndpointPublicNetworkDetails = (request, defaults) => ({});
193
+ const marshalDeploymentQuantization = (request, defaults) => ({
194
+ bits: request.bits
195
+ });
196
+ const marshalEndpointSpec = (request, defaults) => ({
197
+ disable_auth: request.disableAuth,
198
+ ...sdkClient.resolveOneOf([
199
+ {
200
+ param: "public_network",
201
+ value: request.publicNetwork !== void 0 ? marshalEndpointPublicNetworkDetails(request.publicNetwork) : void 0
202
+ },
203
+ {
204
+ param: "private_network",
205
+ value: request.privateNetwork !== void 0 ? marshalEndpointPrivateNetworkDetails(
206
+ request.privateNetwork
207
+ ) : void 0
208
+ }
209
+ ])
210
+ });
211
+ const marshalCreateDeploymentRequest = (request, defaults) => ({
212
+ accept_eula: request.acceptEula,
213
+ endpoints: request.endpoints.map((elt) => marshalEndpointSpec(elt)),
214
+ max_size: request.maxSize,
215
+ min_size: request.minSize,
216
+ model_id: request.modelId,
217
+ name: request.name || randomName("inference"),
218
+ node_type_name: request.nodeTypeName,
219
+ project_id: request.projectId ?? defaults.defaultProjectId,
220
+ quantization: request.quantization !== void 0 ? marshalDeploymentQuantization(request.quantization) : void 0,
221
+ tags: request.tags
222
+ });
223
+ const marshalCreateEndpointRequest = (request, defaults) => ({
224
+ deployment_id: request.deploymentId,
225
+ endpoint: marshalEndpointSpec(request.endpoint)
226
+ });
227
+ const marshalModelSource = (request, defaults) => ({
228
+ url: request.url,
229
+ ...sdkClient.resolveOneOf([{ param: "secret", value: request.secret }])
230
+ });
231
+ const marshalCreateModelRequest = (request, defaults) => ({
232
+ name: request.name || randomName("model"),
233
+ project_id: request.projectId ?? defaults.defaultProjectId,
234
+ source: marshalModelSource(request.source)
235
+ });
236
+ const marshalUpdateDeploymentRequest = (request, defaults) => ({
237
+ max_size: request.maxSize,
238
+ min_size: request.minSize,
239
+ model_id: request.modelId,
240
+ name: request.name,
241
+ quantization: request.quantization !== void 0 ? marshalDeploymentQuantization(request.quantization) : void 0,
242
+ tags: request.tags
243
+ });
244
+ const marshalUpdateEndpointRequest = (request, defaults) => ({
245
+ disable_auth: request.disableAuth
246
+ });
247
+ exports.marshalCreateDeploymentRequest = marshalCreateDeploymentRequest;
248
+ exports.marshalCreateEndpointRequest = marshalCreateEndpointRequest;
249
+ exports.marshalCreateModelRequest = marshalCreateModelRequest;
250
+ exports.marshalUpdateDeploymentRequest = marshalUpdateDeploymentRequest;
251
+ exports.marshalUpdateEndpointRequest = marshalUpdateEndpointRequest;
252
+ exports.unmarshalDeployment = unmarshalDeployment;
253
+ exports.unmarshalEndpoint = unmarshalEndpoint;
254
+ exports.unmarshalListDeploymentsResponse = unmarshalListDeploymentsResponse;
255
+ exports.unmarshalListModelsResponse = unmarshalListModelsResponse;
256
+ exports.unmarshalListNodeTypesResponse = unmarshalListNodeTypesResponse;
257
+ exports.unmarshalModel = unmarshalModel;
258
+ exports.unmarshalModelSupportInfo = unmarshalModelSupportInfo;
@@ -0,0 +1,14 @@
1
+ import type { DefaultValues } from '@scaleway/sdk-client';
2
+ import type { CreateDeploymentRequest, CreateEndpointRequest, CreateModelRequest, Deployment, Endpoint, ListDeploymentsResponse, ListModelsResponse, ListNodeTypesResponse, Model, ModelSupportInfo, UpdateDeploymentRequest, UpdateEndpointRequest } from './types.gen';
3
+ export declare const unmarshalEndpoint: (data: unknown) => Endpoint;
4
+ export declare const unmarshalModelSupportInfo: (data: unknown) => ModelSupportInfo;
5
+ export declare const unmarshalDeployment: (data: unknown) => Deployment;
6
+ export declare const unmarshalModel: (data: unknown) => Model;
7
+ export declare const unmarshalListDeploymentsResponse: (data: unknown) => ListDeploymentsResponse;
8
+ export declare const unmarshalListModelsResponse: (data: unknown) => ListModelsResponse;
9
+ export declare const unmarshalListNodeTypesResponse: (data: unknown) => ListNodeTypesResponse;
10
+ export declare const marshalCreateDeploymentRequest: (request: CreateDeploymentRequest, defaults: DefaultValues) => Record<string, unknown>;
11
+ export declare const marshalCreateEndpointRequest: (request: CreateEndpointRequest, defaults: DefaultValues) => Record<string, unknown>;
12
+ export declare const marshalCreateModelRequest: (request: CreateModelRequest, defaults: DefaultValues) => Record<string, unknown>;
13
+ export declare const marshalUpdateDeploymentRequest: (request: UpdateDeploymentRequest, defaults: DefaultValues) => Record<string, unknown>;
14
+ export declare const marshalUpdateEndpointRequest: (request: UpdateEndpointRequest, defaults: DefaultValues) => Record<string, unknown>;