Skip to content

Commit 1b9c9ec

Browse files
committed
[API] Updates inference endpoints
1 parent d42830d commit 1b9c9ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2474
-95
lines changed

elasticsearch-api/lib/elasticsearch/api/actions/inference/stream_inference.rb renamed to elasticsearch-api/lib/elasticsearch/api/actions/inference/chat_completion_unified.rb

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,31 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
#
18-
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19-
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
18+
# Auto generated from commit 69cbe7cbe9f49a2886bb419ec847cffb58f8b4fb
19+
# @see https://github.com/elastic/elasticsearch-specification
2020
#
2121
module Elasticsearch
2222
module API
2323
module Inference
2424
module Actions
25-
# Perform streaming inference
25+
# Perform chat completion inference
2626
#
27-
# @option arguments [String] :inference_id The inference Id
28-
# @option arguments [String] :task_type The task type
27+
# @option arguments [String] :inference_id The inference Id (*Required*)
28+
# @option arguments [Time] :timeout Specifies the amount of time to wait for the inference request to complete. Server default: 30s.
2929
# @option arguments [Hash] :headers Custom HTTP headers
30-
# @option arguments [Hash] :body The inference payload
30+
# @option arguments [Hash] :body chat_completion_request
3131
#
32-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/post-stream-inference-api.html
32+
# @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-unified-inference
3333
#
34-
def stream_inference(arguments = {})
35-
request_opts = { endpoint: arguments[:endpoint] || 'inference.stream_inference' }
34+
def chat_completion_unified(arguments = {})
35+
request_opts = { endpoint: arguments[:endpoint] || 'inference.chat_completion_unified' }
3636

37-
defined_params = %i[inference_id task_type].each_with_object({}) do |variable, set_variables|
37+
defined_params = [:inference_id].each_with_object({}) do |variable, set_variables|
3838
set_variables[variable] = arguments[variable] if arguments.key?(variable)
3939
end
4040
request_opts[:defined_params] = defined_params unless defined_params.empty?
4141

42+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
4243
raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id]
4344

4445
arguments = arguments.clone
@@ -48,15 +49,9 @@ def stream_inference(arguments = {})
4849

4950
_inference_id = arguments.delete(:inference_id)
5051

51-
_task_type = arguments.delete(:task_type)
52-
5352
method = Elasticsearch::API::HTTP_POST
54-
path = if _task_type && _inference_id
55-
"_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_inference_id)}/_stream"
56-
else
57-
"_inference/#{Utils.__listify(_inference_id)}/_stream"
58-
end
59-
params = {}
53+
path = "_inference/chat_completion/#{Utils.listify(_inference_id)}/_stream"
54+
params = Utils.process_params(arguments)
6055

6156
Elasticsearch::API::Response.new(
6257
perform_request(method, path, params, body, headers, request_opts)

elasticsearch-api/lib/elasticsearch/api/actions/inference/inference.rb renamed to elasticsearch-api/lib/elasticsearch/api/actions/inference/completion.rb

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,26 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
#
18-
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19-
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
18+
# Auto generated from commit 69cbe7cbe9f49a2886bb419ec847cffb58f8b4fb
19+
# @see https://github.com/elastic/elasticsearch-specification
2020
#
2121
module Elasticsearch
2222
module API
2323
module Inference
2424
module Actions
25-
# Perform inference
25+
# Perform completion inference on the service
2626
#
27-
# @option arguments [String] :inference_id The inference Id
28-
# @option arguments [String] :task_type The task type
27+
# @option arguments [String] :inference_id The inference Id (*Required*)
28+
# @option arguments [Time] :timeout Specifies the amount of time to wait for the inference request to complete. Server default: 30s.
2929
# @option arguments [Hash] :headers Custom HTTP headers
30-
# @option arguments [Hash] :body The inference payload
30+
# @option arguments [Hash] :body request body
3131
#
32-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/post-inference-api.html
32+
# @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-inference
3333
#
34-
def inference(arguments = {})
35-
request_opts = { endpoint: arguments[:endpoint] || 'inference.inference' }
34+
def completion(arguments = {})
35+
request_opts = { endpoint: arguments[:endpoint] || 'inference.completion' }
3636

37-
defined_params = %i[inference_id task_type].each_with_object({}) do |variable, set_variables|
37+
defined_params = [:inference_id].each_with_object({}) do |variable, set_variables|
3838
set_variables[variable] = arguments[variable] if arguments.key?(variable)
3939
end
4040
request_opts[:defined_params] = defined_params unless defined_params.empty?
@@ -48,15 +48,9 @@ def inference(arguments = {})
4848

4949
_inference_id = arguments.delete(:inference_id)
5050

51-
_task_type = arguments.delete(:task_type)
52-
5351
method = Elasticsearch::API::HTTP_POST
54-
path = if _task_type && _inference_id
55-
"_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_inference_id)}"
56-
else
57-
"_inference/#{Utils.__listify(_inference_id)}"
58-
end
59-
params = {}
52+
path = "_inference/completion/#{Utils.listify(_inference_id)}"
53+
params = Utils.process_params(arguments)
6054

6155
Elasticsearch::API::Response.new(
6256
perform_request(method, path, params, body, headers, request_opts)

elasticsearch-api/lib/elasticsearch/api/actions/inference/delete.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,27 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
#
18-
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19-
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
18+
# Auto generated from commit c34efd13258a01121b10a538e5b450b4e65c7bf3
19+
# @see https://github.com/elastic/elasticsearch-specification
2020
#
2121
module Elasticsearch
2222
module API
2323
module Inference
2424
module Actions
2525
# Delete an inference endpoint
2626
#
27-
# @option arguments [String] :inference_id The inference Id
2827
# @option arguments [String] :task_type The task type
29-
# @option arguments [Boolean] :dry_run If true the endpoint will not be deleted and a list of ingest processors which reference this endpoint will be returned.
30-
# @option arguments [Boolean] :force If true the endpoint will be forcefully stopped (regardless of whether or not it is referenced by any ingest processors or semantic text fields).
28+
# @option arguments [String] :inference_id The inference identifier. (*Required*)
29+
# @option arguments [Boolean] :dry_run When true, the endpoint is not deleted and a list of ingest processors which reference this endpoint is returned.
30+
# @option arguments [Boolean] :force When true, the inference endpoint is forcefully deleted even if it is still being used by ingest processors or semantic text fields.
3131
# @option arguments [Hash] :headers Custom HTTP headers
3232
#
33-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference-api.html
33+
# @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-delete
3434
#
3535
def delete(arguments = {})
3636
request_opts = { endpoint: arguments[:endpoint] || 'inference.delete' }
3737

38-
defined_params = %i[inference_id task_type].each_with_object({}) do |variable, set_variables|
38+
defined_params = [:inference_id, :task_type].each_with_object({}) do |variable, set_variables|
3939
set_variables[variable] = arguments[variable] if arguments.key?(variable)
4040
end
4141
request_opts[:defined_params] = defined_params unless defined_params.empty?
@@ -47,15 +47,15 @@ def delete(arguments = {})
4747

4848
body = nil
4949

50-
_inference_id = arguments.delete(:inference_id)
51-
5250
_task_type = arguments.delete(:task_type)
5351

52+
_inference_id = arguments.delete(:inference_id)
53+
5454
method = Elasticsearch::API::HTTP_DELETE
5555
path = if _task_type && _inference_id
56-
"_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_inference_id)}"
56+
"_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}"
5757
else
58-
"_inference/#{Utils.__listify(_inference_id)}"
58+
"_inference/#{Utils.listify(_inference_id)}"
5959
end
6060
params = Utils.process_params(arguments)
6161

elasticsearch-api/lib/elasticsearch/api/actions/inference/get.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,25 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
#
18-
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19-
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
18+
# Auto generated from commit c34efd13258a01121b10a538e5b450b4e65c7bf3
19+
# @see https://github.com/elastic/elasticsearch-specification
2020
#
2121
module Elasticsearch
2222
module API
2323
module Inference
2424
module Actions
2525
# Get an inference endpoint
2626
#
27-
# @option arguments [String] :inference_id The inference Id
2827
# @option arguments [String] :task_type The task type
28+
# @option arguments [String] :inference_id The inference Id
2929
# @option arguments [Hash] :headers Custom HTTP headers
3030
#
31-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/get-inference-api.html
31+
# @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-get
3232
#
3333
def get(arguments = {})
3434
request_opts = { endpoint: arguments[:endpoint] || 'inference.get' }
3535

36-
defined_params = %i[inference_id task_type].each_with_object({}) do |variable, set_variables|
36+
defined_params = [:inference_id, :task_type].each_with_object({}) do |variable, set_variables|
3737
set_variables[variable] = arguments[variable] if arguments.key?(variable)
3838
end
3939
request_opts[:defined_params] = defined_params unless defined_params.empty?
@@ -43,15 +43,15 @@ def get(arguments = {})
4343

4444
body = nil
4545

46-
_inference_id = arguments.delete(:inference_id)
47-
4846
_task_type = arguments.delete(:task_type)
4947

48+
_inference_id = arguments.delete(:inference_id)
49+
5050
method = Elasticsearch::API::HTTP_GET
5151
path = if _task_type && _inference_id
52-
"_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_inference_id)}"
52+
"_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}"
5353
elsif _inference_id
54-
"_inference/#{Utils.__listify(_inference_id)}"
54+
"_inference/#{Utils.listify(_inference_id)}"
5555
else
5656
'_inference'
5757
end
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Licensed to Elasticsearch B.V. under one or more contributor
2+
# license agreements. See the NOTICE file distributed with
3+
# this work for additional information regarding copyright
4+
# ownership. Elasticsearch B.V. licenses this file to you under
5+
# the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
# Auto generated from commit c34efd13258a01121b10a538e5b450b4e65c7bf3
19+
# @see https://github.com/elastic/elasticsearch-specification
20+
#
21+
module Elasticsearch
22+
module API
23+
module Inference
24+
module Actions
25+
# Perform a chat completion task through the Elastic Inference Service (EIS).
26+
# Perform a chat completion inference task with the +elastic+ service.
27+
#
28+
# @option arguments [String] :eis_inference_id The unique identifier of the inference endpoint. (*Required*)
29+
# @option arguments [Hash] :headers Custom HTTP headers
30+
# @option arguments [Hash] :body chat_completion_request
31+
#
32+
# @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-post-eis-chat-completion
33+
#
34+
def post_eis_chat_completion(arguments = {})
35+
request_opts = { endpoint: arguments[:endpoint] || 'inference.post_eis_chat_completion' }
36+
37+
defined_params = [:eis_inference_id].each_with_object({}) do |variable, set_variables|
38+
set_variables[variable] = arguments[variable] if arguments.key?(variable)
39+
end
40+
request_opts[:defined_params] = defined_params unless defined_params.empty?
41+
42+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
43+
raise ArgumentError, "Required argument 'eis_inference_id' missing" unless arguments[:eis_inference_id]
44+
45+
arguments = arguments.clone
46+
headers = arguments.delete(:headers) || {}
47+
48+
body = arguments.delete(:body)
49+
50+
_eis_inference_id = arguments.delete(:eis_inference_id)
51+
52+
method = Elasticsearch::API::HTTP_POST
53+
path = "_inference/chat_completion/#{Utils.listify(_eis_inference_id)}/_stream"
54+
params = {}
55+
56+
Elasticsearch::API::Response.new(
57+
perform_request(method, path, params, body, headers, request_opts)
58+
)
59+
end
60+
end
61+
end
62+
end
63+
end

elasticsearch-api/lib/elasticsearch/api/actions/inference/put.rb

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,55 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
#
18-
# Auto generated from build hash f284cc16f4d4b4289bc679aa1529bb504190fe80
19-
# @see https://github.com/elastic/elasticsearch/tree/main/rest-api-spec
18+
# Auto generated from commit c34efd13258a01121b10a538e5b450b4e65c7bf3
19+
# @see https://github.com/elastic/elasticsearch-specification
2020
#
2121
module Elasticsearch
2222
module API
2323
module Inference
2424
module Actions
25-
# Configure an inference endpoint for use in the Inference API
25+
# Create an inference endpoint.
26+
# When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
27+
# After creating the endpoint, wait for the model deployment to complete before using it.
28+
# To verify the deployment status, use the get trained model statistics API.
29+
# Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+.
30+
# Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.
31+
# 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, Mistral, Azure OpenAI, Google AI Studio, Google Vertex AI, Anthropic, Watsonx.ai, or Hugging Face.
32+
# For built-in models and models uploaded through Eland, the inference APIs offer an alternative way to use and manage trained models.
33+
# 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.
2634
#
27-
# @option arguments [String] :inference_id The inference Id
2835
# @option arguments [String] :task_type The task type
36+
# @option arguments [String] :inference_id The inference Id (*Required*)
2937
# @option arguments [Hash] :headers Custom HTTP headers
30-
# @option arguments [Hash] :body The inference endpoint's task and service settings
38+
# @option arguments [Hash] :body inference_config
3139
#
32-
# @see https://www.elastic.co/guide/en/elasticsearch/reference/current/put-inference-api.html
40+
# @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put
3341
#
3442
def put(arguments = {})
3543
request_opts = { endpoint: arguments[:endpoint] || 'inference.put' }
3644

37-
defined_params = %i[inference_id task_type].each_with_object({}) do |variable, set_variables|
45+
defined_params = [:inference_id, :task_type].each_with_object({}) do |variable, set_variables|
3846
set_variables[variable] = arguments[variable] if arguments.key?(variable)
3947
end
4048
request_opts[:defined_params] = defined_params unless defined_params.empty?
4149

50+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
4251
raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id]
4352

4453
arguments = arguments.clone
4554
headers = arguments.delete(:headers) || {}
4655

4756
body = arguments.delete(:body)
4857

49-
_inference_id = arguments.delete(:inference_id)
50-
5158
_task_type = arguments.delete(:task_type)
5259

60+
_inference_id = arguments.delete(:inference_id)
61+
5362
method = Elasticsearch::API::HTTP_PUT
5463
path = if _task_type && _inference_id
55-
"_inference/#{Utils.__listify(_task_type)}/#{Utils.__listify(_inference_id)}"
64+
"_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_inference_id)}"
5665
else
57-
"_inference/#{Utils.__listify(_inference_id)}"
66+
"_inference/#{Utils.listify(_inference_id)}"
5867
end
5968
params = {}
6069

0 commit comments

Comments
 (0)