|
| 1 | +# Licensed to Elasticsearch B.V. under one or more contributor |
| 2 | +# license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright |
| 4 | +# ownership. Elasticsearch B.V. licenses this file to you under |
| 5 | +# the Apache License, Version 2.0 (the "License"); you may |
| 6 | +# not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | +# |
| 18 | +# Auto generated from commit f284cc16f4d4b4289bc679aa1529bb504190fe80 |
| 19 | +# @see https://github.com/elastic/elasticsearch-specification |
| 20 | +# |
| 21 | +module Elasticsearch |
| 22 | + module API |
| 23 | + module Inference |
| 24 | + module Actions |
| 25 | + # Create an Anthropic inference endpoint. |
| 26 | + # Create an inference endpoint to perform an inference task with the +anthropic+ service. |
| 27 | + # When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running. |
| 28 | + # After creating the endpoint, wait for the model deployment to complete before using it. |
| 29 | + # To verify the deployment status, use the get trained model statistics API. |
| 30 | + # Look for +"state": "fully_allocated"+ in the response and ensure that the +"allocation_count"+ matches the +"target_allocation_count"+. |
| 31 | + # Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources. |
| 32 | + # |
| 33 | + # @option arguments [String] :task_type The task type. |
| 34 | + # The only valid task type for the model to perform is +completion+. (*Required*) |
| 35 | + # @option arguments [String] :anthropic_inference_id The unique identifier of the inference endpoint. (*Required*) |
| 36 | + # @option arguments [Hash] :headers Custom HTTP headers |
| 37 | + # @option arguments [Hash] :body request body |
| 38 | + # |
| 39 | + # @see https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-anthropic |
| 40 | + # |
| 41 | + def put_anthropic(arguments = {}) |
| 42 | + request_opts = { endpoint: arguments[:endpoint] || 'inference.put_anthropic' } |
| 43 | + |
| 44 | + defined_params = [:task_type, :anthropic_inference_id].each_with_object({}) do |variable, set_variables| |
| 45 | + set_variables[variable] = arguments[variable] if arguments.key?(variable) |
| 46 | + end |
| 47 | + request_opts[:defined_params] = defined_params unless defined_params.empty? |
| 48 | + |
| 49 | + raise ArgumentError, "Required argument 'task_type' missing" unless arguments[:task_type] |
| 50 | + |
| 51 | + unless arguments[:anthropic_inference_id] |
| 52 | + raise ArgumentError, |
| 53 | + "Required argument 'anthropic_inference_id' missing" |
| 54 | + end |
| 55 | + |
| 56 | + arguments = arguments.clone |
| 57 | + headers = arguments.delete(:headers) || {} |
| 58 | + |
| 59 | + body = arguments.delete(:body) |
| 60 | + |
| 61 | + _task_type = arguments.delete(:task_type) |
| 62 | + |
| 63 | + _anthropic_inference_id = arguments.delete(:anthropic_inference_id) |
| 64 | + |
| 65 | + method = Elasticsearch::API::HTTP_PUT |
| 66 | + path = "_inference/#{Utils.listify(_task_type)}/#{Utils.listify(_anthropic_inference_id)}" |
| 67 | + params = {} |
| 68 | + |
| 69 | + Elasticsearch::API::Response.new( |
| 70 | + perform_request(method, path, params, body, headers, request_opts) |
| 71 | + ) |
| 72 | + end |
| 73 | + end |
| 74 | + end |
| 75 | + end |
| 76 | +end |
0 commit comments