Skip to content

Commit dc0cd55

Browse files
committed
Add inference.stream_inference
1 parent 2efcd2c commit dc0cd55

File tree

10 files changed

+299
-12
lines changed

10 files changed

+299
-12
lines changed

compiler/src/model/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ export function hoistRequestAnnotations (
670670
'manage_enrich', 'manage_ilm', 'manage_index_templates', 'manage_inference', 'manage_ingest_pipelines', 'manage_logstash_pipelines',
671671
'manage_ml', 'manage_oidc', 'manage_own_api_key', 'manage_pipeline', 'manage_rollup', 'manage_saml',
672672
'manage_security', 'manage_service_account', 'manage_slm', 'manage_token', 'manage_transform', 'manage_user_profile',
673-
'manage_watcher', 'monitor', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure',
673+
'manage_watcher', 'monitor', 'monitor_inference', 'monitor_ml', 'monitor_rollup', 'monitor_snapshot', 'monitor_text_structure',
674674
'monitor_transform', 'monitor_watcher', 'read_ccr', 'read_ilm', 'read_pipeline', 'read_security', 'read_slm', 'transport_client'
675675
]
676676
const values = parseCommaSeparated(value)

docs/overlays/elasticsearch-openapi-overlays.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,4 +391,12 @@ actions:
391391
application/json:
392392
examples:
393393
indicesLegacyPutTemplateRequestExample1:
394-
$ref: "../../specification/indices/put_template/indicesPutTemplateRequestExample1.yaml"
394+
$ref: "../../specification/indices/put_template/indicesPutTemplateRequestExample1.yaml"
395+
- target: "$.components['requestBodies']['inference.stream_inference']"
396+
description: "Add example for inference stream request"
397+
update:
398+
content:
399+
application/json:
400+
examples:
401+
streamInferenceRequestExample1:
402+
$ref: "../../specification/inference/stream_inference/StreamInferenceRequestExample1.yaml"

output/openapi/elasticsearch-openapi.json

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

output/schema/schema.json

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

output/schema/validation-errors.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,6 @@
450450
],
451451
"response": []
452452
},
453-
"inference.stream_inference": {
454-
"request": [
455-
"Missing request & response"
456-
],
457-
"response": []
458-
},
459453
"ingest.delete_geoip_database": {
460454
"request": [
461455
"Request: query parameter 'master_timeout' does not exist in the json spec",

output/typescript/types.ts

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

specification/_doc_ids/table.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ indices-stats,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/i
257257
indices-templates,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/indices-templates.html
258258
indices-update-settings,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/indices-update-settings.html
259259
infer-trained-model-deployment,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/infer-trained-model-deployment.html
260+
inference-api-stream,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/stream-inference-api.html
260261
inference-processor,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/inference-processor.html
261262
info-api,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/info-api.html
262263
ingest,https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/ingest.html
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 '@inference/_types/TaskType'
21+
import { RequestBase } from '@_types/Base'
22+
import { Id } from '@_types/common'
23+
24+
/**
25+
* Perform streaming inference.
26+
* Get real-time responses for completion tasks by delivering answers incrementally, reducing response times during computation.
27+
* This API works only with the completion task type.
28+
*
29+
* IMPORTANT: The inference APIs enable you to use certain services, such as built-in machine learning models (ELSER, E5), models uploaded through Eland, Cohere, OpenAI, Azure, Google AI Studio, Google Vertex AI, Anthropic, Watsonx.ai, or Hugging Face. For built-in models and models uploaded through Eland, the inference APIs offer an alternative way to use and manage trained models. However, if you do not plan to use the inference APIs to use these models or if you want to use non-NLP models, use the machine learning trained model APIs.
30+
*
31+
* This API requires the `monitor_inference` cluster privilege (the built-in `inference_admin` and `inference_user` roles grant this privilege). You must use a client that supports streaming.
32+
* @rest_spec_name inference.stream_inference
33+
* @availability stack since=8.16.0 stability=stable visibility=public
34+
* @cluster_privileges monitor_inference
35+
* @doc_id inference-api-stream
36+
*/
37+
export interface Request extends RequestBase {
38+
path_parts: {
39+
/**
40+
* The unique identifier for the inference endpoint.
41+
*/
42+
inference_id: Id
43+
/**
44+
* The type of task that the model performs.
45+
*/
46+
task_type?: TaskType
47+
}
48+
body: {
49+
/**
50+
* The text on which you want to perform the inference task.
51+
* It can be a single string or an array.
52+
*
53+
* NOTE: Inference endpoints for the completion task type currently only support a single string as input.
54+
*/
55+
input: string
56+
}
57+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
summary: Perform a completion task
2+
description: Run `POST _inference/completion/openai-completion/_stream` to perform a completion on the example question with streaming.
3+
# method_request: "POST _inference/completion/openai-completion/_stream"
4+
# type: "request"
5+
value:
6+
input: 'What is Elastic?'
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
export class Response {
21+
body: {}
22+
}

0 commit comments

Comments
 (0)