From 408461a16a83c2821aeb0629c2c23486e28c2ba9 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 8 Apr 2025 13:04:21 +0100 Subject: [PATCH 1/2] [API] Removes inference EIS endpoints --- .../inference/post_eis_chat_completion.rb | 63 ----------------- .../api/actions/inference/put_eis.rb | 67 ------------------- .../lib/elasticsearch/api/version.rb | 2 +- .../post_eis_chat_completion_spec.rb | 36 ---------- .../unit/actions/inference/put_eis_spec.rb | 36 ---------- 5 files changed, 1 insertion(+), 203 deletions(-) delete mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/post_eis_chat_completion.rb delete mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_eis.rb delete mode 100644 elasticsearch-api/spec/unit/actions/inference/post_eis_chat_completion_spec.rb delete mode 100644 elasticsearch-api/spec/unit/actions/inference/put_eis_spec.rb diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/post_eis_chat_completion.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/post_eis_chat_completion.rb deleted file mode 100644 index 0ec1f8e064..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/post_eis_chat_completion.rb +++ /dev/null @@ -1,63 +0,0 @@ -# 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. -# -# This code was automatically generated from the Elasticsearch Specification -# See https://github.com/elastic/elasticsearch-specification -# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. -module Elasticsearch - module API - module Inference - module Actions - # Perform a chat completion task through the Elastic Inference Service (EIS). - # Perform a chat completion inference task with the +elastic+ service. - # - # @option arguments [String] :eis_inference_id The unique identifier of the inference endpoint. (*Required*) - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body chat_completion_request - # - # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-post-eis-chat-completion - # - def post_eis_chat_completion(arguments = {}) - request_opts = { endpoint: arguments[:endpoint] || 'inference.post_eis_chat_completion' } - - defined_params = [:eis_inference_id].each_with_object({}) do |variable, set_variables| - set_variables[variable] = arguments[variable] if arguments.key?(variable) - end - request_opts[:defined_params] = defined_params unless defined_params.empty? - - raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] - raise ArgumentError, "Required argument 'eis_inference_id' missing" unless arguments[:eis_inference_id] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - _eis_inference_id = arguments.delete(:eis_inference_id) - - method = Elasticsearch::API::HTTP_POST - path = "_inference/chat_completion/#{Utils.listify(_eis_inference_id)}/_stream" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers, request_opts) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_eis.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_eis.rb deleted file mode 100644 index 1be0cf8425..0000000000 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_eis.rb +++ /dev/null @@ -1,67 +0,0 @@ -# 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. -# -# This code was automatically generated from the Elasticsearch Specification -# See https://github.com/elastic/elasticsearch-specification -# See Elasticsearch::ES_SPECIFICATION_COMMIT for commit hash. -module Elasticsearch - module API - module Inference - module Actions - # Create an Elastic Inference Service (EIS) inference endpoint. - # Create an inference endpoint to perform an inference task through the Elastic Inference Service (EIS). - # - # @option arguments [String] :task_type The type of the inference task that the model will perform. - # NOTE: The +chat_completion+ task type only supports streaming and only through the _stream API. (*Required*) - # @option arguments [String] :eis_inference_id The unique identifier of the inference endpoint. (*Required*) - # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body request body - # - # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-eis - # - def put_eis(arguments = {}) - request_opts = { endpoint: arguments[:endpoint] || 'inference.put_eis' } - - defined_params = [:task_type, :eis_inference_id].each_with_object({}) do |variable, set_variables| - set_variables[variable] = arguments[variable] if arguments.key?(variable) - end - request_opts[:defined_params] = defined_params unless defined_params.empty? - - raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] - raise ArgumentError, "Required argument 'eis_inference_id' missing" unless arguments[:eis_inference_id] - - arguments = arguments.clone - headers = arguments.delete(:headers) || {} - - body = arguments.delete(:body) - - _task_type = arguments.delete(:task_type) - - _eis_inference_id = arguments.delete(:eis_inference_id) - - method = Elasticsearch::API::HTTP_PUT - path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_eis_inference_id)}" - params = {} - - Elasticsearch::API::Response.new( - perform_request(method, path, params, body, headers, request_opts) - ) - end - end - end - end -end diff --git a/elasticsearch-api/lib/elasticsearch/api/version.rb b/elasticsearch-api/lib/elasticsearch/api/version.rb index 8003e0d5ac..72fc9bb45c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/version.rb +++ b/elasticsearch-api/lib/elasticsearch/api/version.rb @@ -18,6 +18,6 @@ module Elasticsearch module API VERSION = '9.0.0'.freeze - ES_SPECIFICATION_COMMIT = 'dbb89db180052524cab77d324be4f0c00972807a'.freeze + ES_SPECIFICATION_COMMIT = 'be826b018f81ab6339c42a62077f7651c768421b'.freeze end end diff --git a/elasticsearch-api/spec/unit/actions/inference/post_eis_chat_completion_spec.rb b/elasticsearch-api/spec/unit/actions/inference/post_eis_chat_completion_spec.rb deleted file mode 100644 index b5e62acf81..0000000000 --- a/elasticsearch-api/spec/unit/actions/inference/post_eis_chat_completion_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -# 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. - -require 'spec_helper' - -describe 'client#inference.post_eis_chat_completion' do - let(:expected_args) do - [ - 'POST', - '_inference/chat_completion/foo/_stream', - {}, - {}, - {}, - { defined_params: { eis_inference_id: 'foo' }, - endpoint: 'inference.post_eis_chat_completion' } - ] - end - - it 'performs the request' do - expect(client_double.inference.post_eis_chat_completion(body: {}, eis_inference_id: 'foo')).to be_a Elasticsearch::API::Response - end -end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_eis_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_eis_spec.rb deleted file mode 100644 index fefea73059..0000000000 --- a/elasticsearch-api/spec/unit/actions/inference/put_eis_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -# 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. - -require 'spec_helper' - -describe 'client#inference.put_eis' do - let(:expected_args) do - [ - 'PUT', - '_inference/foo/bar', - {}, - nil, - {}, - { defined_params: { eis_inference_id: 'bar', task_type: 'foo' }, - endpoint: 'inference.put_eis' } - ] - end - - it 'performs the request' do - expect(client_double.inference.put_eis(task_type: 'foo', eis_inference_id: 'bar')).to be_a Elasticsearch::API::Response - end -end From ca8e7d402ae5fddb7eb028b7ab40c2b53e19da8a Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 8 Apr 2025 13:46:53 +0100 Subject: [PATCH 2/2] Updates perform_request_spec --- elasticsearch-api/spec/unit/perform_request_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elasticsearch-api/spec/unit/perform_request_spec.rb b/elasticsearch-api/spec/unit/perform_request_spec.rb index cade50b6f1..6860194075 100644 --- a/elasticsearch-api/spec/unit/perform_request_spec.rb +++ b/elasticsearch-api/spec/unit/perform_request_spec.rb @@ -27,7 +27,7 @@ spec.visibility != 'public' || # TODO: Once the test suite is migrated to elasticsearch-specification, these should be removed spec.module_namespace.flatten.first == 'rollup' || - ['scroll', 'clear_scroll', 'connector.last_sync'].include?(spec.endpoint_name) + ['scroll', 'clear_scroll', 'connector.last_sync', 'inference.put_eis'].include?(spec.endpoint_name) # These are the path parts defined by the user in the method argument defined_path_parts = spec.path_params.inject({}) do |params, part|