@daocloud-proto/infery 0.0.0-dev-6e9d6274 → 0.0.0-dev-f59c3dee

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.
package/fetch.pb.ts CHANGED
@@ -338,4 +338,21 @@ export function renderURLSearchParams<T extends RequestPayload>(
338
338
  );
339
339
 
340
340
  return new URLSearchParams(urlSearchParams).toString();
341
- }
341
+ }
342
+
343
+ export async function fetchRawReq(path: string, init?: InitReq): Promise<Response> {
344
+ const {pathPrefix, ...req} = init || {}
345
+ const url = pathPrefix ? `${pathPrefix}${path}` : path
346
+ const response = await fetch(url, req)
347
+ if (!response.ok) {
348
+ const text = await response.text()
349
+ let body: unknown = text
350
+ try {
351
+ body = JSON.parse(text)
352
+ } catch {
353
+ // Preserve a non-JSON error body when an intermediary does not use the gateway error schema.
354
+ }
355
+ throw body
356
+ }
357
+ return response
358
+ }
@@ -8,6 +8,15 @@ import * as InferyCommonCommon from "../../../common/common.pb"
8
8
  import * as fm from "../../../fetch.pb"
9
9
  import * as GoogleProtobufTimestamp from "../../../google/protobuf/timestamp.pb"
10
10
 
11
+ type Absent<T, K extends keyof T> = { [k in Exclude<keyof T, K>]?: undefined };
12
+ type OneOf<T> =
13
+ | { [k in keyof T]?: undefined }
14
+ | (
15
+ keyof T extends infer K ?
16
+ (K extends string & keyof T ? { [k in K]: T[K] } & Absent<T, K>
17
+ : never)
18
+ : never);
19
+
11
20
  export enum Maturity {
12
21
  MATURITY_UNSPECIFIED = "MATURITY_UNSPECIFIED",
13
22
  MATURITY_PRODUCTION = "MATURITY_PRODUCTION",
@@ -76,18 +85,28 @@ export type InferenceTemplate = {
76
85
  spec?: InferenceTemplateSpec
77
86
  }
78
87
 
79
- export type ModelServingReference = {
80
- name?: string
81
- configurationRevision?: string
82
- }
83
88
 
84
- export type ExportInferenceTemplateRequest = {
89
+ type BaseExportInferenceTemplateRequest = {
85
90
  workspace?: number
86
- modelServing?: ModelServingReference
91
+ modelServingName?: string
87
92
  templateName?: string
88
93
  maturity?: Maturity
89
94
  }
90
95
 
96
+ export type ExportInferenceTemplateRequest = BaseExportInferenceTemplateRequest
97
+ & OneOf<{ version: string }>
98
+
99
+ export type ParseInferenceTemplateRequest = {
100
+ workspace?: number
101
+ manifest?: InferenceTemplateManifest
102
+ }
103
+
104
+ export type ParseInferenceTemplateResponse = {
105
+ name?: string
106
+ maturity?: Maturity
107
+ guide?: InferyCommonCommon.I18nName
108
+ }
109
+
91
110
  export type CreateInferenceTemplateRequest = {
92
111
  workspace?: number
93
112
  name?: string
@@ -142,8 +161,11 @@ export type DeleteInferenceTemplateRequest = {
142
161
  }
143
162
 
144
163
  export class InferenceTemplateManagement {
145
- static ExportInferenceTemplate(req: ExportInferenceTemplateRequest, initReq?: fm.InitReq): Promise<InferenceTemplateManifest> {
146
- return fm.fetchReq<ExportInferenceTemplateRequest, InferenceTemplateManifest>(`/apis/infery.io/v1alpha1/workspaces/${req["workspace"]}/inference-templates:export`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
164
+ static ExportInferenceTemplate(req: ExportInferenceTemplateRequest, initReq?: fm.InitReq): Promise<Response> {
165
+ return fm.fetchRawReq(`/apis/infery.io/v1alpha1/workspaces/${req["workspace"]}/inference-templates:export?${fm.renderURLSearchParams(req, ["workspace"])}`, {...initReq, method: "GET"})
166
+ }
167
+ static ParseInferenceTemplate(req: ParseInferenceTemplateRequest, initReq?: fm.InitReq): Promise<ParseInferenceTemplateResponse> {
168
+ return fm.fetchReq<ParseInferenceTemplateRequest, ParseInferenceTemplateResponse>(`/apis/infery.io/v1alpha1/workspaces/${req["workspace"]}/inference-templates:parse`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
147
169
  }
148
170
  static CreateInferenceTemplate(req: CreateInferenceTemplateRequest, initReq?: fm.InitReq): Promise<InferenceTemplate> {
149
171
  return fm.fetchReq<CreateInferenceTemplateRequest, InferenceTemplate>(`/apis/infery.io/v1alpha1/workspaces/${req["workspace"]}/inference-templates`, {...initReq, method: "POST", body: JSON.stringify(req, fm.replacer)})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daocloud-proto/infery",
3
- "version": "v0.0.0-dev-6e9d6274",
3
+ "version": "v0.0.0-dev-f59c3dee",
4
4
  "description": "Infery frontend protobuf SDK",
5
5
  "license": "ISC"
6
6
  }