Skip to content

Add _inference API #2329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Dec 7, 2023
Merged
643 changes: 635 additions & 8 deletions output/schema/schema.json

Large diffs are not rendered by default.

199,924 changes: 199,924 additions & 0 deletions output/schema/schema/schema.json

Large diffs are not rendered by default.

1,560 changes: 1,560 additions & 0 deletions output/schema/schema/validation-errors.json

Large diffs are not rendered by default.

22 changes: 5 additions & 17 deletions output/schema/validation-errors.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 69 additions & 0 deletions output/typescript/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 53 additions & 0 deletions specification/inference/_types/Results.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { float } from '@_types/Numeric'
import { Dictionary } from '@spec_utils/Dictionary'

/**
* Sparse Embedding tokens are represented as a dictionary
* of string to double.
*/
export type SparseVector = Dictionary<string, float>

/**
* Text Embedding results are represented as Dense Vectors
* of floats.
*/
export type DenseVector = Array<float>

export class SparseEmbeddingResult {
embedding: SparseVector
}

/**
* The text embedding result object
*/
export class TextEmbeddingResult {
embedding: DenseVector
}

/**
* InferenceResult is an aggregation of mutually exclusive variants
* @variants container
*/
export class InferenceResult {
text_embedding?: Array<TextEmbeddingResult>
sparse_embedding?: Array<SparseEmbeddingResult>
}
57 changes: 57 additions & 0 deletions specification/inference/_types/Services.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { TaskType } from '../_types/TaskType'
import { UserDefinedValue } from '@spec_utils/UserDefinedValue'

/**
* Configuration options when storing the model config
*/
export class ModelConfig {
/**
* The service type
*/
service: string
/**
* Settings specific to the service
*/
service_settings: ServiceSettings
/**
* Task settings specific to the service and model
*/
task_settings: TaskSettings
}

/**
* Represents a model as returned by the GET API
*/
export class ModelConfigContainer extends ModelConfig {
/**
* The model Id
*/
model_id: string
/**
* The model's task type
*/
task_type: TaskType
}

export type ServiceSettings = UserDefinedValue

export type TaskSettings = UserDefinedValue
26 changes: 26 additions & 0 deletions specification/inference/_types/TaskType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/**
* Task types used in the API
*/
export enum TaskType {
sparse_embedding = 0,
text_embedding = 1
}
41 changes: 41 additions & 0 deletions specification/inference/delete_model/DeleteModelRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { RequestBase } from '@_types/Base'
import { Id } from '@_types/common'
import { TaskType } from '@inference/_types/TaskType'

/**
* Delete an inference service model
* @rest_spec_name inference.delete_model
* @availability stack since=8.11.0 stability=experimental visibility=public
* @availability serverless stability=experimental visibility=private
*/
export interface Request extends RequestBase {
path_parts: {
/**
* The model task type
*/
task_type: TaskType
/**
* The unique identifier of the inference model.
*/
model_id: Id
}
}
24 changes: 24 additions & 0 deletions specification/inference/delete_model/DeleteModelResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { AcknowledgedResponseBase } from '@_types/Base'

export class Response {
body: AcknowledgedResponseBase
}
41 changes: 41 additions & 0 deletions specification/inference/get_model/GetModelRequest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { RequestBase } from '@_types/Base'
import { Id } from '@_types/common'
import { TaskType } from '@inference/_types/TaskType'

/**
* Get an inference service model
* @rest_spec_name inference.get_model
* @availability stack since=8.11.0 stability=experimental visibility=public
* @availability serverless stability=experimental visibility=private
*/
export interface Request extends RequestBase {
path_parts: {
/**
* The model task type
*/
task_type: TaskType
/**
* The unique identifier of the inference model.
*/
model_id: Id
}
}
26 changes: 26 additions & 0 deletions specification/inference/get_model/GetModelResponse.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { ModelConfigContainer } from '@inference/_types/Services'

export class Response {
body: {
models: Array<ModelConfigContainer>
}
}
Loading