From 45b29d7aee04299e66b4a1871e93bad187679c88 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 1 Apr 2025 09:24:24 +0100 Subject: [PATCH 1/3] [API] Auto generated code, updates source code documentation * esql.async_query, esql.query - Add Boolean parameter :allow_partial_results. * indices.exists_index_template - Adds Boolean parameters: :local, :flat_settings. * indices.field_usage_states - Removes :wait_for_active_shards parameter. * indices.put_settings - Adds Boolean parameter :reopen. * indices.reload_search_analyzers - Adds String parameter :resource. * indices.rollover - Adds Boolean parameter :lazy. * indices.simulate_index_template - Adds Boolean parameter :create and String parameter :cause. * indices.simulate_template - Adds String parameter :cause. * inference.chat_completion_unified - Argument body is now required. * open_point_in_time - Adds Integer parameter :max_concurrent_shard_requests. --- .../lib/elasticsearch/api/actions/delete_by_query.rb | 2 +- .../lib/elasticsearch/api/actions/esql/async_query.rb | 1 + .../lib/elasticsearch/api/actions/esql/query.rb | 1 + .../lib/elasticsearch/api/actions/indices/analyze.rb | 2 +- .../api/actions/indices/exists_index_template.rb | 2 ++ .../elasticsearch/api/actions/indices/field_usage_stats.rb | 2 -- .../lib/elasticsearch/api/actions/indices/put_settings.rb | 3 +++ .../lib/elasticsearch/api/actions/indices/put_template.rb | 2 +- .../api/actions/indices/reload_search_analyzers.rb | 1 + .../lib/elasticsearch/api/actions/indices/rollover.rb | 2 ++ .../api/actions/indices/simulate_index_template.rb | 2 ++ .../elasticsearch/api/actions/indices/simulate_template.rb | 1 + .../api/actions/inference/chat_completion_unified.rb | 3 ++- elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb | 1 + .../lib/elasticsearch/api/actions/open_point_in_time.rb | 1 + .../lib/elasticsearch/api/actions/update_by_query.rb | 2 +- .../lib/elasticsearch/api/actions/watcher/update_settings.rb | 5 ++++- .../unit/actions/inference/chat_completion_unified_spec.rb | 4 ++-- 18 files changed, 27 insertions(+), 10 deletions(-) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query.rb index edc6d85cf8..1e3c970df0 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/delete_by_query.rb @@ -96,7 +96,7 @@ module Actions # @option arguments [String, Array] :expand_wildcards The type of index that wildcard patterns can match. # If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. # It supports comma-separated values, such as +open,hidden+. Server default: open. - # @option arguments [Integer] :from Starting offset (default: 0) + # @option arguments [Integer] :from Skips the specified number of documents. Server default: 0. # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. # @option arguments [Boolean] :lenient If +true+, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. # This parameter can be used only when the +q+ query string parameter is specified. diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query.rb index 290a1632f2..4a6ea2064c 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/esql/async_query.rb @@ -26,6 +26,7 @@ module Actions # Asynchronously run an ES|QL (Elasticsearch query language) query, monitor its progress, and retrieve results when they become available. # The API accepts the same parameters and request body as the synchronous query API, along with additional async related properties. # + # @option arguments [Boolean] :allow_partial_results If +true+, partial results will be returned if there are shard failures, but the query can continue to execute on other clusters and shards. # @option arguments [String] :delimiter The character to use between values within a CSV row. # It is valid only for the CSV format. # @option arguments [Boolean] :drop_null_columns Indicates whether columns that are entirely +null+ will be removed from the +columns+ and +values+ portion of the results. diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/esql/query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/esql/query.rb index cfda90c2a7..baed554358 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/esql/query.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/esql/query.rb @@ -32,6 +32,7 @@ module Actions # @option arguments [String] :delimiter The character to use between values within a CSV row. Only valid for the CSV format. # @option arguments [Boolean] :drop_null_columns Should columns that are entirely +null+ be removed from the +columns+ and +values+ portion of the results? # Defaults to +false+. If +true+ then the response will include an extra section under the name +all_columns+ which has the name of all columns. + # @option arguments [Boolean] :allow_partial_results If +true+, partial results will be returned if there are shard failures, but the query can continue to execute on other clusters and shards. # @option arguments [Hash] :headers Custom HTTP headers # @option arguments [Hash] :body request body # diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/analyze.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/analyze.rb index f6fb85a312..fd30b6c1fc 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/analyze.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/analyze.rb @@ -63,7 +63,7 @@ def analyze(arguments = {}) else '_analyze' end - params = {} + params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_index_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_index_template.rb index b2cbdf23ff..0c8fa3d14d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_index_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/exists_index_template.rb @@ -26,6 +26,8 @@ module Actions # Check whether index templates exist. # # @option arguments [String] :name Comma-separated list of index template names used to limit the request. Wildcard (*) expressions are supported. (*Required*) + # @option arguments [Boolean] :local If true, the request retrieves information from the local node only. Defaults to false, which means information is retrieved from the master node. + # @option arguments [Boolean] :flat_settings If true, returns settings in flat format. # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers # diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/field_usage_stats.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/field_usage_stats.rb index f011c41b19..266d08258d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/field_usage_stats.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/field_usage_stats.rb @@ -42,8 +42,6 @@ module Actions # Supports comma-separated values, such as +open,hidden+. # @option arguments [Boolean] :ignore_unavailable If +true+, missing or closed indices are not included in the response. # @option arguments [String, Array] :fields Comma-separated list or wildcard expressions of fields to include in the statistics. - # @option arguments [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. - # Set to all or any positive integer up to the total number of shards in the index (+number_of_replicas+1+). Server default: 1. # @option arguments [Hash] :headers Custom HTTP headers # # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-field-usage-stats diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_settings.rb index 7b4802d47f..91a281aa3f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_settings.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_settings.rb @@ -55,6 +55,9 @@ module Actions # received before the timeout expires, the request fails and returns an # error. Server default: 30s. # @option arguments [Boolean] :preserve_existing If +true+, existing index settings remain unchanged. + # @option arguments [Boolean] :reopen Whether to close and reopen the index to apply non-dynamic settings. + # If set to +true+ the indices to which the settings are being applied + # will be closed temporarily and then reopened in order to apply the changes. # @option arguments [Time] :timeout Period to wait for a response. If no response is received before the # timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_template.rb index 1a84024197..feda545521 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/put_template.rb @@ -45,7 +45,7 @@ module Actions # @option arguments [Integer] :order Order in which Elasticsearch applies this template if index # matches multiple templates.Templates with lower 'order' values are merged first. Templates with higher # 'order' values are merged later, overriding templates with lower values. - # @option arguments [String] :cause [TODO] + # @option arguments [String] :cause User defined reason for creating/updating the index template # @option arguments [Hash] :headers Custom HTTP headers # @option arguments [Hash] :body request body # diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/reload_search_analyzers.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/reload_search_analyzers.rb index dc84b403ed..669838409d 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/reload_search_analyzers.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/reload_search_analyzers.rb @@ -38,6 +38,7 @@ module Actions # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes +_all+ string or when no indices have been specified) # @option arguments [String, Array] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) + # @option arguments [String] :resource Changed resource to reload analyzers from if applicable # @option arguments [Hash] :headers Custom HTTP headers # # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-indices-reload-search-analyzers diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb index 3d2aea201f..89c04a418b 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/rollover.rb @@ -60,6 +60,8 @@ module Actions # If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Integer, String] :wait_for_active_shards The number of shard copies that must be active before proceeding with the operation. # Set to all or any positive integer up to the total number of shards in the index (+number_of_replicas+1+). Server default: 1. + # @option arguments [Boolean] :lazy If set to true, the rollover action will only mark a data stream to signal that it needs to be rolled over at the next write. + # Only allowed on data streams. # @option arguments [Hash] :headers Custom HTTP headers # @option arguments [Hash] :body request body # diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_index_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_index_template.rb index 5c25b779da..57ba4a41e6 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_index_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_index_template.rb @@ -26,6 +26,8 @@ module Actions # Get the index configuration that would be applied to the specified index from an existing index template. # # @option arguments [String] :name Name of the index to simulate (*Required*) + # @option arguments [Boolean] :create Whether the index template we optionally defined in the body should only be dry-run added if new or can also replace an existing one + # @option arguments [String] :cause User defined reason for dry-run creating the new template for simulation purposes Server default: false. # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Boolean] :include_defaults If true, returns all relevant default configurations for the index template. # @option arguments [Hash] :headers Custom HTTP headers diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_template.rb b/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_template.rb index ff23b60c61..0fd79acbfb 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_template.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/indices/simulate_template.rb @@ -28,6 +28,7 @@ module Actions # @option arguments [String] :name Name of the index template to simulate. To test a template configuration before you add it to the cluster, omit # this parameter and specify the template configuration in the request body. # @option arguments [Boolean] :create If true, the template passed in the body is only used if no existing templates match the same index patterns. If false, the simulation uses the template with the highest priority. Note that the template is not permanently added or updated in either case; it is only used for the simulation. + # @option arguments [String] :cause User defined reason for dry-run creating the new template for simulation purposes # @option arguments [Time] :master_timeout Period to wait for a connection to the master node. If no response is received before the timeout expires, the request fails and returns an error. Server default: 30s. # @option arguments [Boolean] :include_defaults If true, returns all relevant default configurations for the index template. # @option arguments [Hash] :headers Custom HTTP headers diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/inference/chat_completion_unified.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/chat_completion_unified.rb index a1efed0125..37ad6f25b7 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/inference/chat_completion_unified.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/chat_completion_unified.rb @@ -27,7 +27,7 @@ module Actions # @option arguments [String] :inference_id The inference Id (*Required*) # @option arguments [Time] :timeout Specifies the amount of time to wait for the inference request to complete. Server default: 30s. # @option arguments [Hash] :headers Custom HTTP headers - # @option arguments [Hash] :body request body + # @option arguments [Hash] :body chat_completion_request # # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-unified-inference # @@ -39,6 +39,7 @@ def chat_completion_unified(arguments = {}) end request_opts[:defined_params] = defined_params unless defined_params.empty? + raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'inference_id' missing" unless arguments[:inference_id] arguments = arguments.clone diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb index d28a78406a..f3fe43fe4f 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/msearch.rb @@ -48,6 +48,7 @@ module Actions # Typically, this adds a small overhead to a request. # However, using computationally expensive named queries on a large number of hits may add significant overhead. # @option arguments [Integer] :max_concurrent_searches Maximum number of concurrent searches the multi search API can execute. + # Defaults to +max(1, (# of data nodes * min(search thread pool size, 10)))+. # @option arguments [Integer] :max_concurrent_shard_requests Maximum number of concurrent shard requests that each sub-search request executes per node. Server default: 5. # @option arguments [Integer] :pre_filter_shard_size Defines a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method i.e., if date filters are mandatory to match but the shard bounds and the query are disjoint. # @option arguments [Boolean] :rest_total_hits_as_int If true, hits.total are returned as an integer in the response. Defaults to false, which returns an object. diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/open_point_in_time.rb b/elasticsearch-api/lib/elasticsearch/api/actions/open_point_in_time.rb index 0ec8e149e7..a4ad4b55e1 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/open_point_in_time.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/open_point_in_time.rb @@ -60,6 +60,7 @@ module Actions # @option arguments [Boolean] :allow_partial_search_results Indicates whether the point in time tolerates unavailable shards or shard failures when initially creating the PIT. # If +false+, creating a point in time request when a shard is missing or unavailable will throw an exception. # If +true+, the point in time will contain all the shards that are available at the time of the request. + # @option arguments [Integer] :max_concurrent_shard_requests Maximum number of concurrent shard requests that each sub-search request executes per node. Server default: 5. # @option arguments [Hash] :headers Custom HTTP headers # @option arguments [Hash] :body request body # diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb b/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb index d61bbfb994..15e8cd6b27 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/update_by_query.rb @@ -101,7 +101,7 @@ module Actions # If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. # It supports comma-separated values, such as +open,hidden+. # Valid values are: +all+, +open+, +closed+, +hidden+, +none+. - # @option arguments [Integer] :from Starting offset (default: 0) + # @option arguments [Integer] :from Skips the specified number of documents. Server default: 0. # @option arguments [Boolean] :ignore_unavailable If +false+, the request returns an error if it targets a missing or closed index. # @option arguments [Boolean] :lenient If +true+, format-based query failures (such as providing text to a numeric field) in the query string will be ignored. # This parameter can be used only when the +q+ query string parameter is specified. diff --git a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/update_settings.rb b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/update_settings.rb index ca087b1fda..fbd96cb35e 100644 --- a/elasticsearch-api/lib/elasticsearch/api/actions/watcher/update_settings.rb +++ b/elasticsearch-api/lib/elasticsearch/api/actions/watcher/update_settings.rb @@ -25,7 +25,10 @@ module Actions # Update Watcher index settings. # Update settings for the Watcher internal index (+.watches+). # Only a subset of settings can be modified. - # This includes +index.auto_expand_replicas+ and +index.number_of_replicas+. + # This includes +index.auto_expand_replicas+, +index.number_of_replicas+, +index.routing.allocation.exclude.*+, + # +index.routing.allocation.include.*+ and +index.routing.allocation.require.*+. + # Modification of +index.routing.allocation.include._tier_preference+ is an exception and is not allowed as the + # Watcher shards must always be in the +data_content+ tier. # # @option arguments [Time] :master_timeout The period to wait for a connection to the master node. # If no response is received before the timeout expires, the request fails and returns an error. diff --git a/elasticsearch-api/spec/unit/actions/inference/chat_completion_unified_spec.rb b/elasticsearch-api/spec/unit/actions/inference/chat_completion_unified_spec.rb index 6abc29076e..180bcb3f64 100644 --- a/elasticsearch-api/spec/unit/actions/inference/chat_completion_unified_spec.rb +++ b/elasticsearch-api/spec/unit/actions/inference/chat_completion_unified_spec.rb @@ -23,7 +23,7 @@ 'POST', '_inference/chat_completion/bar/_stream', {}, - nil, + {}, {}, { defined_params: { inference_id: 'bar' }, endpoint: 'inference.chat_completion_unified' } @@ -31,6 +31,6 @@ end it 'performs the request' do - expect(client_double.inference.chat_completion_unified(inference_id: 'bar')).to be_a Elasticsearch::API::Response + expect(client_double.inference.chat_completion_unified(inference_id: 'bar', body: {})).to be_a Elasticsearch::API::Response end end From 897d5991e7938513bf9e1832069a9ea6bfbfad07 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 1 Apr 2025 09:25:24 +0100 Subject: [PATCH 2/3] [API] Adds new inference PUT endpoints --- .../inference/post_eis_chat_completion.rb | 63 ++++++++++++++ .../api/actions/inference/put_alibabacloud.rb | 75 ++++++++++++++++ .../actions/inference/put_amazonbedrock.rb | 70 +++++++++++++++ .../api/actions/inference/put_anthropic.rb | 76 ++++++++++++++++ .../actions/inference/put_azureaistudio.rb | 75 ++++++++++++++++ .../api/actions/inference/put_azureopenai.rb | 80 +++++++++++++++++ .../api/actions/inference/put_cohere.rb | 75 ++++++++++++++++ .../api/actions/inference/put_eis.rb | 67 +++++++++++++++ .../actions/inference/put_elasticsearch.rb | 71 +++++++++++++++ .../api/actions/inference/put_elser.rb | 67 +++++++++++++++ .../actions/inference/put_googleaistudio.rb | 75 ++++++++++++++++ .../actions/inference/put_googlevertexai.rb | 75 ++++++++++++++++ .../api/actions/inference/put_hugging_face.rb | 86 +++++++++++++++++++ .../api/actions/inference/put_jinaai.rb | 77 +++++++++++++++++ .../api/actions/inference/put_mistral.rb | 76 ++++++++++++++++ .../api/actions/inference/put_openai.rb | 76 ++++++++++++++++ .../api/actions/inference/put_voyageai.rb | 71 +++++++++++++++ .../post_eis_chat_completion_spec.rb | 36 ++++++++ .../inference/put_alibabacloud_spec.rb | 36 ++++++++ .../inference/put_amazonbedrock_spec.rb | 36 ++++++++ .../actions/inference/put_anthropic_spec.rb | 36 ++++++++ .../inference/put_azureaistudio_spec.rb | 36 ++++++++ .../actions/inference/put_azureopenai_spec.rb | 36 ++++++++ .../unit/actions/inference/put_cohere_spec.rb | 36 ++++++++ .../unit/actions/inference/put_eis_spec.rb | 36 ++++++++ .../inference/put_elasticsearch_spec.rb | 36 ++++++++ .../unit/actions/inference/put_elser_spec.rb | 36 ++++++++ .../inference/put_googleaistudio_spec.rb | 36 ++++++++ .../inference/put_googlevertexai_spec.rb | 36 ++++++++ .../inference/put_hugging_face_spec.rb | 36 ++++++++ .../unit/actions/inference/put_jinaai_spec.rb | 36 ++++++++ .../actions/inference/put_mistral_spec.rb | 36 ++++++++ .../unit/actions/inference/put_openai_spec.rb | 36 ++++++++ .../actions/inference/put_voyageai_spec.rb | 36 ++++++++ 34 files changed, 1867 insertions(+) create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/post_eis_chat_completion.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_alibabacloud.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonbedrock.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_anthropic.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureaistudio.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureopenai.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_cohere.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_eis.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elasticsearch.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elser.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googleaistudio.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googlevertexai.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_hugging_face.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_jinaai.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_mistral.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_openai.rb create mode 100644 elasticsearch-api/lib/elasticsearch/api/actions/inference/put_voyageai.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/post_eis_chat_completion_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_alibabacloud_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_amazonbedrock_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_anthropic_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_azureaistudio_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_azureopenai_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_cohere_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_eis_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_elasticsearch_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_elser_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_googleaistudio_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_googlevertexai_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_hugging_face_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_jinaai_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_mistral_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_openai_spec.rb create mode 100644 elasticsearch-api/spec/unit/actions/inference/put_voyageai_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 new file mode 100644 index 0000000000..021d4cc477 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/post_eis_chat_completion.rb @@ -0,0 +1,63 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +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_alibabacloud.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_alibabacloud.rb new file mode 100644 index 0000000000..149a7332bb --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_alibabacloud.rb @@ -0,0 +1,75 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create an AlibabaCloud AI Search inference endpoint. + # Create an inference endpoint to perform an inference task with the +alibabacloud-ai-search+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :alibabacloud_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-alibabacloud + # + def put_alibabacloud(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_alibabacloud' } + + defined_params = [:task_type, :alibabacloud_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] + + unless arguments[:alibabacloud_inference_id] + raise ArgumentError, + "Required argument 'alibabacloud_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _alibabacloud_inference_id = arguments.delete(:alibabacloud_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_alibabacloud_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/actions/inference/put_amazonbedrock.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonbedrock.rb new file mode 100644 index 0000000000..b640715b96 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_amazonbedrock.rb @@ -0,0 +1,70 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create an Amazon Bedrock inference endpoint. + # Creates an inference endpoint to perform an inference task with the +amazonbedrock+ service. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :amazonbedrock_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-amazonbedrock + # + def put_amazonbedrock(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_amazonbedrock' } + + defined_params = [:task_type, :amazonbedrock_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] + + unless arguments[:amazonbedrock_inference_id] + raise ArgumentError, + "Required argument 'amazonbedrock_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _amazonbedrock_inference_id = arguments.delete(:amazonbedrock_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_amazonbedrock_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/actions/inference/put_anthropic.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_anthropic.rb new file mode 100644 index 0000000000..2f64cf7f3d --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_anthropic.rb @@ -0,0 +1,76 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create an Anthropic inference endpoint. + # Create an inference endpoint to perform an inference task with the +anthropic+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The task type. + # The only valid task type for the model to perform is +completion+. (*Required*) + # @option arguments [String] :anthropic_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-anthropic + # + def put_anthropic(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_anthropic' } + + defined_params = [:task_type, :anthropic_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] + + unless arguments[:anthropic_inference_id] + raise ArgumentError, + "Required argument 'anthropic_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _anthropic_inference_id = arguments.delete(:anthropic_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_anthropic_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/actions/inference/put_azureaistudio.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureaistudio.rb new file mode 100644 index 0000000000..7d522638de --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureaistudio.rb @@ -0,0 +1,75 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create an Azure AI studio inference endpoint. + # Create an inference endpoint to perform an inference task with the +azureaistudio+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :azureaistudio_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-azureaistudio + # + def put_azureaistudio(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_azureaistudio' } + + defined_params = [:task_type, :azureaistudio_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] + + unless arguments[:azureaistudio_inference_id] + raise ArgumentError, + "Required argument 'azureaistudio_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _azureaistudio_inference_id = arguments.delete(:azureaistudio_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_azureaistudio_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/actions/inference/put_azureopenai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureopenai.rb new file mode 100644 index 0000000000..82c9790a28 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_azureopenai.rb @@ -0,0 +1,80 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create an Azure OpenAI inference endpoint. + # Create an inference endpoint to perform an inference task with the +azureopenai+ service. + # The list of chat completion models that you can choose from in your Azure OpenAI deployment include: + # * {https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#gpt-4-and-gpt-4-turbo-models GPT-4 and GPT-4 Turbo models} + # * {https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#gpt-35 GPT-3.5} + # The list of embeddings models that you can choose from in your deployment can be found in the {https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#embeddings Azure models documentation}. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @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] :azureopenai_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-azureopenai + # + def put_azureopenai(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_azureopenai' } + + defined_params = [:task_type, :azureopenai_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] + + unless arguments[:azureopenai_inference_id] + raise ArgumentError, + "Required argument 'azureopenai_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _azureopenai_inference_id = arguments.delete(:azureopenai_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_azureopenai_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/actions/inference/put_cohere.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_cohere.rb new file mode 100644 index 0000000000..fca7d54e36 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_cohere.rb @@ -0,0 +1,75 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create a Cohere inference endpoint. + # Create an inference endpoint to perform an inference task with the +cohere+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :cohere_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-cohere + # + def put_cohere(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_cohere' } + + defined_params = [:task_type, :cohere_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] + + unless arguments[:cohere_inference_id] + raise ArgumentError, + "Required argument 'cohere_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _cohere_inference_id = arguments.delete(:cohere_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_cohere_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/actions/inference/put_eis.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_eis.rb new file mode 100644 index 0000000000..18ef9312f4 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_eis.rb @@ -0,0 +1,67 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +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/actions/inference/put_elasticsearch.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elasticsearch.rb new file mode 100644 index 0000000000..10dd102dea --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elasticsearch.rb @@ -0,0 +1,71 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create an Elasticsearch inference endpoint. + # Create an inference endpoint to perform an inference task with the +elasticsearch+ service. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :elasticsearch_inference_id The unique identifier of the inference endpoint. + # The must not match the +model_id+. (*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-elasticsearch + # + def put_elasticsearch(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_elasticsearch' } + + defined_params = [:task_type, :elasticsearch_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] + + unless arguments[:elasticsearch_inference_id] + raise ArgumentError, + "Required argument 'elasticsearch_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _elasticsearch_inference_id = arguments.delete(:elasticsearch_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_elasticsearch_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/actions/inference/put_elser.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elser.rb new file mode 100644 index 0000000000..cb615f12f8 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_elser.rb @@ -0,0 +1,67 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create an ELSER inference endpoint. + # Create an inference endpoint to perform an inference task with the +elser+ service. + # You can also deploy ELSER by using the Elasticsearch inference integration. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :elser_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-elser + # + def put_elser(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_elser' } + + defined_params = [:task_type, :elser_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 'elser_inference_id' missing" unless arguments[:elser_inference_id] + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _elser_inference_id = arguments.delete(:elser_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_elser_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/actions/inference/put_googleaistudio.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googleaistudio.rb new file mode 100644 index 0000000000..b95fdec10e --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googleaistudio.rb @@ -0,0 +1,75 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create an Google AI Studio inference endpoint. + # Create an inference endpoint to perform an inference task with the +googleaistudio+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :googleaistudio_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-googleaistudio + # + def put_googleaistudio(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_googleaistudio' } + + defined_params = [:task_type, :googleaistudio_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] + + unless arguments[:googleaistudio_inference_id] + raise ArgumentError, + "Required argument 'googleaistudio_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _googleaistudio_inference_id = arguments.delete(:googleaistudio_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_googleaistudio_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/actions/inference/put_googlevertexai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googlevertexai.rb new file mode 100644 index 0000000000..cee610674a --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_googlevertexai.rb @@ -0,0 +1,75 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create a Google Vertex AI inference endpoint. + # Create an inference endpoint to perform an inference task with the +googlevertexai+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :googlevertexai_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-googlevertexai + # + def put_googlevertexai(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_googlevertexai' } + + defined_params = [:task_type, :googlevertexai_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] + + unless arguments[:googlevertexai_inference_id] + raise ArgumentError, + "Required argument 'googlevertexai_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _googlevertexai_inference_id = arguments.delete(:googlevertexai_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_googlevertexai_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/actions/inference/put_hugging_face.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_hugging_face.rb new file mode 100644 index 0000000000..9d9e455afc --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_hugging_face.rb @@ -0,0 +1,86 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create a Hugging Face inference endpoint. + # Create an inference endpoint to perform an inference task with the +hugging_face+ service. + # You must first create an inference endpoint on the Hugging Face endpoint page to get an endpoint URL. + # Select the model you want to use on the new endpoint creation page (for example +intfloat/e5-small-v2+), then select the sentence embeddings task under the advanced configuration section. + # Create the endpoint and copy the URL after the endpoint initialization has been finished. + # The following models are recommended for the Hugging Face service: + # * +all-MiniLM-L6-v2+ + # * +all-MiniLM-L12-v2+ + # * +all-mpnet-base-v2+ + # * +e5-base-v2+ + # * +e5-small-v2+ + # * +multilingual-e5-base+ + # * +multilingual-e5-small+ + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :huggingface_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-hugging-face + # + def put_hugging_face(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_hugging_face' } + + defined_params = [:task_type, :huggingface_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] + + unless arguments[:huggingface_inference_id] + raise ArgumentError, + "Required argument 'huggingface_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _huggingface_inference_id = arguments.delete(:huggingface_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_huggingface_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/actions/inference/put_jinaai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_jinaai.rb new file mode 100644 index 0000000000..780face86d --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_jinaai.rb @@ -0,0 +1,77 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create an JinaAI inference endpoint. + # Create an inference endpoint to perform an inference task with the +jinaai+ service. + # To review the available +rerank+ models, refer to . + # To review the available +text_embedding+ models, refer to the . + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :jinaai_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-jinaai + # + def put_jinaai(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_jinaai' } + + defined_params = [:task_type, :jinaai_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] + + unless arguments[:jinaai_inference_id] + raise ArgumentError, + "Required argument 'jinaai_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _jinaai_inference_id = arguments.delete(:jinaai_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_jinaai_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/actions/inference/put_mistral.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_mistral.rb new file mode 100644 index 0000000000..40481c076e --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_mistral.rb @@ -0,0 +1,76 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create a Mistral inference endpoint. + # Creates an inference endpoint to perform an inference task with the +mistral+ service. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The task type. + # The only valid task type for the model to perform is +text_embedding+. (*Required*) + # @option arguments [String] :mistral_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-mistral + # + def put_mistral(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_mistral' } + + defined_params = [:task_type, :mistral_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] + + unless arguments[:mistral_inference_id] + raise ArgumentError, + "Required argument 'mistral_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _mistral_inference_id = arguments.delete(:mistral_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_mistral_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/actions/inference/put_openai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_openai.rb new file mode 100644 index 0000000000..b7581f39b7 --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_openai.rb @@ -0,0 +1,76 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create an OpenAI inference endpoint. + # Create an inference endpoint to perform an inference task with the +openai+ service or +openai+ compatible APIs. + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. + # After creating the endpoint, wait for the model deployment to complete before using it. + # To verify the deployment status, use the get trained model statistics API. + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @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] :openai_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-openai + # + def put_openai(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_openai' } + + defined_params = [:task_type, :openai_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] + + unless arguments[:openai_inference_id] + raise ArgumentError, + "Required argument 'openai_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _openai_inference_id = arguments.delete(:openai_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_openai_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/actions/inference/put_voyageai.rb b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_voyageai.rb new file mode 100644 index 0000000000..877425f3ef --- /dev/null +++ b/elasticsearch-api/lib/elasticsearch/api/actions/inference/put_voyageai.rb @@ -0,0 +1,71 @@ +# 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. +# +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 +# @see https://github.com/elastic/elasticsearch-specification +# +module Elasticsearch + module API + module Inference + module Actions + # Create a VoyageAI inference endpoint. + # Create an inference endpoint to perform an inference task with the +voyageai+ service. + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. + # + # @option arguments [String] :task_type The type of the inference task that the model will perform. (*Required*) + # @option arguments [String] :voyageai_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-voyageai + # + def put_voyageai(arguments = {}) + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_voyageai' } + + defined_params = [:task_type, :voyageai_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] + + unless arguments[:voyageai_inference_id] + raise ArgumentError, + "Required argument 'voyageai_inference_id' missing" + end + + arguments = arguments.clone + headers = arguments.delete(:headers) || {} + + body = arguments.delete(:body) + + _task_type = arguments.delete(:task_type) + + _voyageai_inference_id = arguments.delete(:voyageai_inference_id) + + method = Elasticsearch::API::HTTP_PUT + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_voyageai_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/spec/unit/actions/inference/post_eis_chat_completion_spec.rb b/elasticsearch-api/spec/unit/actions/inference/post_eis_chat_completion_spec.rb new file mode 100644 index 0000000000..b5e62acf81 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/post_eis_chat_completion_spec.rb @@ -0,0 +1,36 @@ +# 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_alibabacloud_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_alibabacloud_spec.rb new file mode 100644 index 0000000000..0ac550822f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_alibabacloud_spec.rb @@ -0,0 +1,36 @@ +# 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_alibabacloud' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { alibabacloud_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_alibabacloud' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_alibabacloud(task_type: 'foo', alibabacloud_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_amazonbedrock_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_amazonbedrock_spec.rb new file mode 100644 index 0000000000..23d5b57c39 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_amazonbedrock_spec.rb @@ -0,0 +1,36 @@ +# 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_amazonbedrock' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { amazonbedrock_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_amazonbedrock' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_amazonbedrock(task_type: 'foo', amazonbedrock_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_anthropic_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_anthropic_spec.rb new file mode 100644 index 0000000000..3f4c22cbba --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_anthropic_spec.rb @@ -0,0 +1,36 @@ +# 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_anthropic' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { anthropic_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_anthropic' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_anthropic(task_type: 'foo', anthropic_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_azureaistudio_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_azureaistudio_spec.rb new file mode 100644 index 0000000000..add3ed7eec --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_azureaistudio_spec.rb @@ -0,0 +1,36 @@ +# 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_azureaistudio' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { azureaistudio_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_azureaistudio' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_azureaistudio(task_type: 'foo', azureaistudio_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_azureopenai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_azureopenai_spec.rb new file mode 100644 index 0000000000..ca0ade65b7 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_azureopenai_spec.rb @@ -0,0 +1,36 @@ +# 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_azureopenai' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { azureopenai_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_azureopenai' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_azureopenai(task_type: 'foo', azureopenai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_cohere_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_cohere_spec.rb new file mode 100644 index 0000000000..7eb82de752 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_cohere_spec.rb @@ -0,0 +1,36 @@ +# 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_cohere' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { cohere_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_cohere' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_cohere(task_type: 'foo', cohere_inference_id: 'bar')).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 new file mode 100644 index 0000000000..fefea73059 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_eis_spec.rb @@ -0,0 +1,36 @@ +# 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 diff --git a/elasticsearch-api/spec/unit/actions/inference/put_elasticsearch_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_elasticsearch_spec.rb new file mode 100644 index 0000000000..e91a89c850 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_elasticsearch_spec.rb @@ -0,0 +1,36 @@ +# 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_elasticsearch' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { elasticsearch_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_elasticsearch' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_elasticsearch(task_type: 'foo', elasticsearch_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_elser_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_elser_spec.rb new file mode 100644 index 0000000000..1862e22721 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_elser_spec.rb @@ -0,0 +1,36 @@ +# 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_elser' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { elser_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_elser' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_elser(task_type: 'foo', elser_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_googleaistudio_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_googleaistudio_spec.rb new file mode 100644 index 0000000000..22c5284990 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_googleaistudio_spec.rb @@ -0,0 +1,36 @@ +# 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_googleaistudio' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { googleaistudio_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_googleaistudio' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_googleaistudio(task_type: 'foo', googleaistudio_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_googlevertexai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_googlevertexai_spec.rb new file mode 100644 index 0000000000..ccf6c883bf --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_googlevertexai_spec.rb @@ -0,0 +1,36 @@ +# 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_googlevertexai' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { googlevertexai_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_googlevertexai' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_googlevertexai(task_type: 'foo', googlevertexai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_hugging_face_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_hugging_face_spec.rb new file mode 100644 index 0000000000..8feb11c28e --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_hugging_face_spec.rb @@ -0,0 +1,36 @@ +# 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_hugging_face' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { huggingface_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_hugging_face' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_hugging_face(task_type: 'foo', huggingface_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_jinaai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_jinaai_spec.rb new file mode 100644 index 0000000000..bcbf0e0f00 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_jinaai_spec.rb @@ -0,0 +1,36 @@ +# 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_jinaai' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { jinaai_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_jinaai' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_jinaai(task_type: 'foo', jinaai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_mistral_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_mistral_spec.rb new file mode 100644 index 0000000000..2d8d8dbd3f --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_mistral_spec.rb @@ -0,0 +1,36 @@ +# 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_mistral' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { mistral_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_mistral' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_mistral(task_type: 'foo', mistral_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_openai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_openai_spec.rb new file mode 100644 index 0000000000..b58dd6e568 --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_openai_spec.rb @@ -0,0 +1,36 @@ +# 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_openai' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { openai_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_openai' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_openai(task_type: 'foo', openai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end diff --git a/elasticsearch-api/spec/unit/actions/inference/put_voyageai_spec.rb b/elasticsearch-api/spec/unit/actions/inference/put_voyageai_spec.rb new file mode 100644 index 0000000000..8bac99b82d --- /dev/null +++ b/elasticsearch-api/spec/unit/actions/inference/put_voyageai_spec.rb @@ -0,0 +1,36 @@ +# 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_voyageai' do + let(:expected_args) do + [ + 'PUT', + '_inference/foo/bar', + {}, + nil, + {}, + { defined_params: { voyageai_inference_id: 'bar', task_type: 'foo' }, + endpoint: 'inference.put_voyageai' } + ] + end + + it 'performs the request' do + expect(client_double.inference.put_voyageai(task_type: 'foo', voyageai_inference_id: 'bar')).to be_a Elasticsearch::API::Response + end +end From c638c4407db96b24401a457c39f1eccc0ab215de Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Tue, 1 Apr 2025 10:18:57 +0100 Subject: [PATCH 3/3] Test: Updates perform_request_spec --- elasticsearch-api/spec/unit/perform_request_spec.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/elasticsearch-api/spec/unit/perform_request_spec.rb b/elasticsearch-api/spec/unit/perform_request_spec.rb index 0b67570705..cade50b6f1 100644 --- a/elasticsearch-api/spec/unit/perform_request_spec.rb +++ b/elasticsearch-api/spec/unit/perform_request_spec.rb @@ -39,15 +39,11 @@ params.merge(part.to_sym => 'testing') end - required_params.merge!(body: {}) if ['inference.put', 'inference.update'].include? spec.endpoint_name + required_params.merge!(body: {}) if ['inference.put', 'inference.update', 'inference.chat_completion_unified'].include? spec.endpoint_name let(:client_double) do Class.new { include Elasticsearch::API }.new.tap do |client| expect(client).to receive(:perform_request) do |_, _, _, _, _, request_params| - # The create method ends up becoming an 'index' request - if expected_perform_request_params[:endpoint] == 'create' - expected_perform_request_params[:endpoint] = 'index' - end # Check that the expected hash is passed to the perform_request method expect(request_params).to eq(expected_perform_request_params) end.and_return(response_double)