From 6ae51983450525d0d7576789b9de358148cf2d67 Mon Sep 17 00:00:00 2001 From: Laura Trotta Date: Mon, 13 Jan 2025 13:10:57 +0100 Subject: [PATCH] update inference response with streamresult type --- output/openapi/elasticsearch-openapi.json | 187 ++++++++-------- output/schema/schema.json | 210 +++++++++--------- output/schema/validation-errors.json | 26 --- output/typescript/types.ts | 22 +- .../StreamInferenceResponse.ts | 4 +- 5 files changed, 219 insertions(+), 230 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index b1d3c783d7..322e4033ff 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -15985,43 +15985,42 @@ "x-state": "Added in 8.11.0" } }, -<<<<<<< HEAD - "/_inference/{inference_id}/_unified": { -======= "/_inference/{inference_id}/_stream": { ->>>>>>> dc0cd555b (Add inference.stream_inference) "post": { "tags": [ "inference" ], -<<<<<<< HEAD - "summary": "Perform inference on the service using the Unified Schema", - "operationId": "inference-unified-inference", + "summary": "Perform streaming inference", + "description": "Get real-time responses for completion tasks by delivering answers incrementally, reducing response times during computation.\nThis API works only with the completion task type.\n\nIMPORTANT: 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.\n\nThis 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.", + "operationId": "inference-stream-inference", "parameters": [ { - "$ref": "#/components/parameters/inference.unified_inference#inference_id" - }, - { - "$ref": "#/components/parameters/inference.unified_inference#timeout" + "$ref": "#/components/parameters/inference.stream_inference#inference_id" } ], "requestBody": { - "$ref": "#/components/requestBodies/inference.unified_inference" + "$ref": "#/components/requestBodies/inference.stream_inference" }, "responses": { "200": { - "$ref": "#/components/responses/inference.unified_inference#200" + "$ref": "#/components/responses/inference.stream_inference#200" } }, - "x-state": "Added in 8.18.0" + "x-state": "Added in 8.16.0" } }, - "/_inference/{task_type}/{inference_id}/_unified": { -======= + "/_inference/{task_type}/{inference_id}/_stream": { + "post": { + "tags": [ + "inference" + ], "summary": "Perform streaming inference", "description": "Get real-time responses for completion tasks by delivering answers incrementally, reducing response times during computation.\nThis API works only with the completion task type.\n\nIMPORTANT: 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.\n\nThis 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.", - "operationId": "inference-stream-inference", + "operationId": "inference-stream-inference-1", "parameters": [ + { + "$ref": "#/components/parameters/inference.stream_inference#task_type" + }, { "$ref": "#/components/parameters/inference.stream_inference#inference_id" } @@ -16037,19 +16036,14 @@ "x-state": "Added in 8.16.0" } }, - "/_inference/{task_type}/{inference_id}/_stream": { ->>>>>>> dc0cd555b (Add inference.stream_inference) + "/_inference/{inference_id}/_unified": { "post": { "tags": [ "inference" ], -<<<<<<< HEAD "summary": "Perform inference on the service using the Unified Schema", - "operationId": "inference-unified-inference-1", + "operationId": "inference-unified-inference", "parameters": [ - { - "$ref": "#/components/parameters/inference.unified_inference#task_type" - }, { "$ref": "#/components/parameters/inference.unified_inference#inference_id" }, @@ -16066,28 +16060,35 @@ } }, "x-state": "Added in 8.18.0" -======= - "summary": "Perform streaming inference", - "description": "Get real-time responses for completion tasks by delivering answers incrementally, reducing response times during computation.\nThis API works only with the completion task type.\n\nIMPORTANT: 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.\n\nThis 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.", - "operationId": "inference-stream-inference-1", + } + }, + "/_inference/{task_type}/{inference_id}/_unified": { + "post": { + "tags": [ + "inference" + ], + "summary": "Perform inference on the service using the Unified Schema", + "operationId": "inference-unified-inference-1", "parameters": [ { - "$ref": "#/components/parameters/inference.stream_inference#task_type" + "$ref": "#/components/parameters/inference.unified_inference#task_type" }, { - "$ref": "#/components/parameters/inference.stream_inference#inference_id" + "$ref": "#/components/parameters/inference.unified_inference#inference_id" + }, + { + "$ref": "#/components/parameters/inference.unified_inference#timeout" } ], "requestBody": { - "$ref": "#/components/requestBodies/inference.stream_inference" + "$ref": "#/components/requestBodies/inference.unified_inference" }, "responses": { "200": { - "$ref": "#/components/responses/inference.stream_inference#200" + "$ref": "#/components/responses/inference.unified_inference#200" } }, - "x-state": "Added in 8.16.0" ->>>>>>> dc0cd555b (Add inference.stream_inference) + "x-state": "Added in 8.18.0" } }, "/_inference/{inference_id}/_update": { @@ -72753,6 +72754,9 @@ "score" ] }, + "_types:StreamResult": { + "type": "object" + }, "inference.unified_inference:Message": { "type": "object", "properties": { @@ -72923,9 +72927,6 @@ "name" ] }, - "_types:StreamResult": { - "type": "object" - }, "_types:ElasticsearchVersionInfo": { "type": "object", "properties": { @@ -94279,20 +94280,22 @@ } } }, -<<<<<<< HEAD - "inference.unified_inference#200": { -======= "inference.stream_inference#200": { ->>>>>>> dc0cd555b (Add inference.stream_inference) "description": "", "content": { "application/json": { "schema": { -<<<<<<< HEAD "$ref": "#/components/schemas/_types:StreamResult" -======= - "type": "object" ->>>>>>> dc0cd555b (Add inference.stream_inference) + } + } + } + }, + "inference.unified_inference#200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/_types:StreamResult" } } } @@ -101746,7 +101749,28 @@ }, "style": "simple" }, -<<<<<<< HEAD + "inference.stream_inference#inference_id": { + "in": "path", + "name": "inference_id", + "description": "The unique identifier for the inference endpoint.", + "required": true, + "deprecated": false, + "schema": { + "$ref": "#/components/schemas/_types:Id" + }, + "style": "simple" + }, + "inference.stream_inference#task_type": { + "in": "path", + "name": "task_type", + "description": "The type of task that the model performs.", + "required": true, + "deprecated": false, + "schema": { + "$ref": "#/components/schemas/inference._types:TaskType" + }, + "style": "simple" + }, "inference.unified_inference#task_type": { "in": "path", "name": "task_type", @@ -101762,12 +101786,6 @@ "in": "path", "name": "inference_id", "description": "The inference Id", -======= - "inference.stream_inference#inference_id": { - "in": "path", - "name": "inference_id", - "description": "The unique identifier for the inference endpoint.", ->>>>>>> dc0cd555b (Add inference.stream_inference) "required": true, "deprecated": false, "schema": { @@ -101775,7 +101793,6 @@ }, "style": "simple" }, -<<<<<<< HEAD "inference.unified_inference#timeout": { "in": "query", "name": "timeout", @@ -101785,18 +101802,6 @@ "$ref": "#/components/schemas/_types:Duration" }, "style": "form" -======= - "inference.stream_inference#task_type": { - "in": "path", - "name": "task_type", - "description": "The type of task that the model performs.", - "required": true, - "deprecated": false, - "schema": { - "$ref": "#/components/schemas/inference._types:TaskType" - }, - "style": "simple" ->>>>>>> dc0cd555b (Add inference.stream_inference) }, "inference.update#inference_id": { "in": "path", @@ -107353,17 +107358,40 @@ }, "required": true }, -<<<<<<< HEAD - "inference.unified_inference": { -======= "inference.stream_inference": { ->>>>>>> dc0cd555b (Add inference.stream_inference) "content": { "application/json": { "schema": { "type": "object", "properties": { -<<<<<<< HEAD + "input": { + "description": "The text on which you want to perform the inference task.\nIt can be a single string or an array.\n\nNOTE: Inference endpoints for the completion task type currently only support a single string as input.", + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { + "type": "string" + } + } + ] + } + }, + "required": [ + "input" + ] + } + } + } + }, + "inference.unified_inference": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { "messages": { "description": "A list of objects representing the conversation.", "type": "array", @@ -107407,25 +107435,6 @@ }, "required": [ "messages" -======= - "input": { - "description": "The text on which you want to perform the inference task.\nIt can be a single string or an array.\n\nNOTE: Inference endpoints for the completion task type currently only support a single string as input.", - "oneOf": [ - { - "type": "string" - }, - { - "type": "array", - "items": { - "type": "string" - } - } - ] - } - }, - "required": [ - "input" ->>>>>>> dc0cd555b (Add inference.stream_inference) ] } } diff --git a/output/schema/schema.json b/output/schema/schema.json index 2497027680..fb2393b9ad 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -8863,93 +8863,93 @@ }, { "availability": { + "serverless": { + "stability": "stable", + "visibility": "public" + }, "stack": { - "since": "8.17.0", + "since": "8.18.0", "stability": "stable", "visibility": "public" } }, - "description": "Update an inference endpoint.\n\nModify `task_settings`, secrets (within `service_settings`), or `num_allocations` for an inference endpoint, depending on the specific endpoint service and `task_type`.\n\nIMPORTANT: 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.\nFor built-in models and models uploaded through Eland, the inference APIs offer an alternative way to use and manage trained models.\nHowever, 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.", - "docId": "inference-api-update", - "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/update-inference-api.html", - "name": "inference.update", - "privileges": { - "cluster": [ - "manage_inference" - ] - }, + "description": "Perform inference on the service using the Unified Schema", + "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/master/unified-inference-api.html", + "name": "inference.unified_inference", "request": { "name": "Request", - "namespace": "inference.update" + "namespace": "inference.unified_inference" }, - "requestBodyRequired": true, + "requestBodyRequired": false, "requestMediaType": [ "application/json" ], "response": { "name": "Response", - "namespace": "inference.update" + "namespace": "inference.unified_inference" }, "responseMediaType": [ - "application/json" + "text/event-stream" ], "urls": [ { "methods": [ "POST" ], - "path": "/_inference/{inference_id}/_update" + "path": "/_inference/{inference_id}/_unified" }, { "methods": [ "POST" ], - "path": "/_inference/{task_type}/{inference_id}/_update" + "path": "/_inference/{task_type}/{inference_id}/_unified" } ] }, { "availability": { - "serverless": { - "stability": "stable", - "visibility": "public" - }, "stack": { - "since": "8.18.0", + "since": "8.17.0", "stability": "stable", "visibility": "public" } }, - "description": "Perform inference on the service using the Unified Schema", - "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/master/unified-inference-api.html", - "name": "inference.unified_inference", + "description": "Update an inference endpoint.\n\nModify `task_settings`, secrets (within `service_settings`), or `num_allocations` for an inference endpoint, depending on the specific endpoint service and `task_type`.\n\nIMPORTANT: 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.\nFor built-in models and models uploaded through Eland, the inference APIs offer an alternative way to use and manage trained models.\nHowever, 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.", + "docId": "inference-api-update", + "docUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/{branch}/update-inference-api.html", + "name": "inference.update", + "privileges": { + "cluster": [ + "manage_inference" + ] + }, "request": { "name": "Request", - "namespace": "inference.unified_inference" + "namespace": "inference.update" }, - "requestBodyRequired": false, + "requestBodyRequired": true, "requestMediaType": [ "application/json" ], "response": { "name": "Response", - "namespace": "inference.unified_inference" + "namespace": "inference.update" }, "responseMediaType": [ - "text/event-stream" + "application/json" ], "urls": [ { "methods": [ "POST" ], - "path": "/_inference/{inference_id}/_unified" + "path": "/_inference/{inference_id}/_update" }, { "methods": [ "POST" ], - "path": "/_inference/{task_type}/{inference_id}/_unified" + "path": "/_inference/{task_type}/{inference_id}/_update" } ] }, @@ -144313,74 +144313,6 @@ "query": [], "specLocation": "inference/stream_inference/StreamInferenceRequest.ts#L24-L57" }, - { - "kind": "response", - "body": { - "kind": "properties", - "properties": [] - }, - "name": { - "name": "Response", - "namespace": "inference.stream_inference" - }, - "specLocation": "inference/stream_inference/StreamInferenceResponse.ts#L20-L22" - }, - { - "kind": "request", - "attachedBehaviors": [ - "CommonQueryParameters" - ], - "body": { - "kind": "value", - "codegenName": "inference_config", - "value": { - "kind": "instance_of", - "type": { - "name": "InferenceEndpoint", - "namespace": "inference._types" - } - } - }, - "description": "Update an inference endpoint.\n\nModify `task_settings`, secrets (within `service_settings`), or `num_allocations` for an inference endpoint, depending on the specific endpoint service and `task_type`.\n\nIMPORTANT: 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.\nFor built-in models and models uploaded through Eland, the inference APIs offer an alternative way to use and manage trained models.\nHowever, 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.", - "inherits": { - "type": { - "name": "RequestBase", - "namespace": "_types" - } - }, - "name": { - "name": "Request", - "namespace": "inference.update" - }, - "path": [ - { - "description": "The unique identifier of the inference endpoint.", - "name": "inference_id", - "required": true, - "type": { - "kind": "instance_of", - "type": { - "name": "Id", - "namespace": "_types" - } - } - }, - { - "description": "The type of inference task that the model performs.", - "name": "task_type", - "required": false, - "type": { - "kind": "instance_of", - "type": { - "name": "TaskType", - "namespace": "inference._types" - } - } - } - ], - "query": [], - "specLocation": "inference/update/UpdateInferenceRequest.ts#L25-L51" - }, { "kind": "response", "body": { @@ -144388,16 +144320,16 @@ "value": { "kind": "instance_of", "type": { - "name": "InferenceEndpointInfo", - "namespace": "inference._types" + "name": "StreamResult", + "namespace": "_types" } } }, "name": { "name": "Response", - "namespace": "inference.update" + "namespace": "inference.stream_inference" }, - "specLocation": "inference/update/UpdateInferenceResponse.ts#L22-L24" + "specLocation": "inference/stream_inference/StreamInferenceResponse.ts#L22-L24" }, { "kind": "interface", @@ -144978,6 +144910,80 @@ ], "specLocation": "inference/unified_inference/UnifiedRequest.ts#L106-L118" }, + { + "kind": "request", + "attachedBehaviors": [ + "CommonQueryParameters" + ], + "body": { + "kind": "value", + "codegenName": "inference_config", + "value": { + "kind": "instance_of", + "type": { + "name": "InferenceEndpoint", + "namespace": "inference._types" + } + } + }, + "description": "Update an inference endpoint.\n\nModify `task_settings`, secrets (within `service_settings`), or `num_allocations` for an inference endpoint, depending on the specific endpoint service and `task_type`.\n\nIMPORTANT: 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.\nFor built-in models and models uploaded through Eland, the inference APIs offer an alternative way to use and manage trained models.\nHowever, 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.", + "inherits": { + "type": { + "name": "RequestBase", + "namespace": "_types" + } + }, + "name": { + "name": "Request", + "namespace": "inference.update" + }, + "path": [ + { + "description": "The unique identifier of the inference endpoint.", + "name": "inference_id", + "required": true, + "type": { + "kind": "instance_of", + "type": { + "name": "Id", + "namespace": "_types" + } + } + }, + { + "description": "The type of inference task that the model performs.", + "name": "task_type", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "TaskType", + "namespace": "inference._types" + } + } + } + ], + "query": [], + "specLocation": "inference/update/UpdateInferenceRequest.ts#L25-L51" + }, + { + "kind": "response", + "body": { + "kind": "value", + "value": { + "kind": "instance_of", + "type": { + "name": "InferenceEndpointInfo", + "namespace": "inference._types" + } + } + }, + "name": { + "name": "Response", + "namespace": "inference.update" + }, + "specLocation": "inference/update/UpdateInferenceResponse.ts#L22-L24" + }, { "kind": "interface", "inherits": { diff --git a/output/schema/validation-errors.json b/output/schema/validation-errors.json index 3ff0079c44..2e2edb86de 100644 --- a/output/schema/validation-errors.json +++ b/output/schema/validation-errors.json @@ -259,32 +259,6 @@ ], "response": [] }, -<<<<<<< HEAD - "inference.stream_inference": { - "request": [ - "Missing request & response" -======= - "ingest.delete_geoip_database": { - "request": [ - "Request: query parameter 'master_timeout' does not exist in the json spec", - "Request: query parameter 'timeout' does not exist in the json spec" - ], - "response": [] - }, - "ingest.delete_ip_location_database": { - "request": [ - "Request: query parameter 'master_timeout' does not exist in the json spec", - "Request: query parameter 'timeout' does not exist in the json spec" - ], - "response": [] - }, - "ingest.get_geoip_database": { - "request": [ - "Request: query parameter 'master_timeout' does not exist in the json spec" ->>>>>>> dc0cd555b (Add inference.stream_inference) - ], - "response": [] - }, "ingest.get_ip_location_database": { "request": [ "Request: query parameter 'master_timeout' does not exist in the json spec" diff --git a/output/typescript/types.ts b/output/typescript/types.ts index b38a858f59..fe049c6636 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -12939,7 +12939,16 @@ export interface InferencePutRequest extends RequestBase { export type InferencePutResponse = InferenceInferenceEndpointInfo -<<<<<<< HEAD +export interface InferenceStreamInferenceRequest extends RequestBase { + inference_id: Id + task_type?: InferenceTaskType + body?: { + input: string | string[] + } +} + +export type InferenceStreamInferenceResponse = StreamResult + export interface InferenceUnifiedInferenceCompletionTool { type: string function: InferenceUnifiedInferenceCompletionToolFunction @@ -13004,17 +13013,6 @@ export interface InferenceUnifiedInferenceToolCall { export interface InferenceUnifiedInferenceToolCallFunction { arguments: string name: string -======= -export interface InferenceStreamInferenceRequest extends RequestBase { - inference_id: Id - task_type?: InferenceTaskType - body?: { - input: string | string[] - } -} - -export interface InferenceStreamInferenceResponse { ->>>>>>> dc0cd555b (Add inference.stream_inference) } export interface InferenceUpdateRequest extends RequestBase { diff --git a/specification/inference/stream_inference/StreamInferenceResponse.ts b/specification/inference/stream_inference/StreamInferenceResponse.ts index 0769bf66cb..74b823bf40 100644 --- a/specification/inference/stream_inference/StreamInferenceResponse.ts +++ b/specification/inference/stream_inference/StreamInferenceResponse.ts @@ -17,6 +17,8 @@ * under the License. */ +import { StreamResult } from '@_types/Binary' + export class Response { - body: {} + body: StreamResult }