Skip to content

Commit 4c51be9

Browse files
authored
Add _inference API (#2329)
1 parent 94dc2d1 commit 4c51be9

File tree

17 files changed

+202607
-25
lines changed

17 files changed

+202607
-25
lines changed

output/schema/schema.json

Lines changed: 635 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/schema/schema/schema.json

Lines changed: 199924 additions & 0 deletions
Large diffs are not rendered by default.

output/schema/schema/validation-errors.json

Lines changed: 1560 additions & 0 deletions
Large diffs are not rendered by default.

output/schema/validation-errors.json

Lines changed: 5 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

output/typescript/types.ts

Lines changed: 69 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { float } from '@_types/Numeric'
21+
import { Dictionary } from '@spec_utils/Dictionary'
22+
23+
/**
24+
* Sparse Embedding tokens are represented as a dictionary
25+
* of string to double.
26+
*/
27+
export type SparseVector = Dictionary<string, float>
28+
29+
/**
30+
* Text Embedding results are represented as Dense Vectors
31+
* of floats.
32+
*/
33+
export type DenseVector = Array<float>
34+
35+
export class SparseEmbeddingResult {
36+
embedding: SparseVector
37+
}
38+
39+
/**
40+
* The text embedding result object
41+
*/
42+
export class TextEmbeddingResult {
43+
embedding: DenseVector
44+
}
45+
46+
/**
47+
* InferenceResult is an aggregation of mutually exclusive variants
48+
* @variants container
49+
*/
50+
export class InferenceResult {
51+
text_embedding?: Array<TextEmbeddingResult>
52+
sparse_embedding?: Array<SparseEmbeddingResult>
53+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { TaskType } from '../_types/TaskType'
21+
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'
22+
23+
/**
24+
* Configuration options when storing the model config
25+
*/
26+
export class ModelConfig {
27+
/**
28+
* The service type
29+
*/
30+
service: string
31+
/**
32+
* Settings specific to the service
33+
*/
34+
service_settings: ServiceSettings
35+
/**
36+
* Task settings specific to the service and model
37+
*/
38+
task_settings: TaskSettings
39+
}
40+
41+
/**
42+
* Represents a model as returned by the GET API
43+
*/
44+
export class ModelConfigContainer extends ModelConfig {
45+
/**
46+
* The model Id
47+
*/
48+
model_id: string
49+
/**
50+
* The model's task type
51+
*/
52+
task_type: TaskType
53+
}
54+
55+
export type ServiceSettings = UserDefinedValue
56+
57+
export type TaskSettings = UserDefinedValue
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/**
21+
* Task types used in the API
22+
*/
23+
export enum TaskType {
24+
sparse_embedding = 0,
25+
text_embedding = 1
26+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { RequestBase } from '@_types/Base'
21+
import { Id } from '@_types/common'
22+
import { TaskType } from '@inference/_types/TaskType'
23+
24+
/**
25+
* Delete an inference service model
26+
* @rest_spec_name inference.delete_model
27+
* @availability stack since=8.11.0 stability=experimental visibility=public
28+
* @availability serverless stability=experimental visibility=private
29+
*/
30+
export interface Request extends RequestBase {
31+
path_parts: {
32+
/**
33+
* The model task type
34+
*/
35+
task_type: TaskType
36+
/**
37+
* The unique identifier of the inference model.
38+
*/
39+
model_id: Id
40+
}
41+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { AcknowledgedResponseBase } from '@_types/Base'
21+
22+
export class Response {
23+
body: AcknowledgedResponseBase
24+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { RequestBase } from '@_types/Base'
21+
import { Id } from '@_types/common'
22+
import { TaskType } from '@inference/_types/TaskType'
23+
24+
/**
25+
* Get an inference service model
26+
* @rest_spec_name inference.get_model
27+
* @availability stack since=8.11.0 stability=experimental visibility=public
28+
* @availability serverless stability=experimental visibility=private
29+
*/
30+
export interface Request extends RequestBase {
31+
path_parts: {
32+
/**
33+
* The model task type
34+
*/
35+
task_type: TaskType
36+
/**
37+
* The unique identifier of the inference model.
38+
*/
39+
model_id: Id
40+
}
41+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
import { ModelConfigContainer } from '@inference/_types/Services'
21+
22+
export class Response {
23+
body: {
24+
models: Array<ModelConfigContainer>
25+
}
26+
}

0 commit comments

Comments
 (0)