@@ -22,37 +22,40 @@ module Elasticsearch
22
22
module API
23
23
module Inference
24
24
module Actions
25
- # Configure an inference endpoint that uses the Elastic Inference Service (EIS)
25
+ # Perform inference
26
26
#
27
+ # @option arguments [String] :inference_id The inference Id
27
28
# @option arguments [String] :task_type The task type
28
- # @option arguments [String] :eis_inference_id The inference ID
29
29
# @option arguments [Hash] :headers Custom HTTP headers
30
- # @option arguments [Hash] :body The inference endpoint's task and service settings
30
+ # @option arguments [Hash] :body The inference payload
31
31
#
32
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.17/infer-service-elastic .html
32
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/8.17/post-inference-api .html
33
33
#
34
- def put_eis ( arguments = { } )
35
- request_opts = { endpoint : arguments [ :endpoint ] || 'inference.put_eis ' }
34
+ def inference ( arguments = { } )
35
+ request_opts = { endpoint : arguments [ :endpoint ] || 'inference.inference ' }
36
36
37
- defined_params = %i[ task_type eis_inference_id ] . each_with_object ( { } ) do |variable , set_variables |
37
+ defined_params = %i[ inference_id task_type ] . each_with_object ( { } ) do |variable , set_variables |
38
38
set_variables [ variable ] = arguments [ variable ] if arguments . key? ( variable )
39
39
end
40
40
request_opts [ :defined_params ] = defined_params unless defined_params . empty?
41
41
42
- raise ArgumentError , "Required argument 'task_type' missing" unless arguments [ :task_type ]
43
- raise ArgumentError , "Required argument 'eis_inference_id' missing" unless arguments [ :eis_inference_id ]
42
+ raise ArgumentError , "Required argument 'inference_id' missing" unless arguments [ :inference_id ]
44
43
45
44
arguments = arguments . clone
46
45
headers = arguments . delete ( :headers ) || { }
47
46
48
47
body = arguments . delete ( :body )
49
48
50
- _task_type = arguments . delete ( :task_type )
49
+ _inference_id = arguments . delete ( :inference_id )
51
50
52
- _eis_inference_id = arguments . delete ( :eis_inference_id )
51
+ _task_type = arguments . delete ( :task_type )
53
52
54
- method = Elasticsearch ::API ::HTTP_PUT
55
- path = "_inference/#{ Utils . __listify ( _task_type ) } /#{ Utils . __listify ( _eis_inference_id ) } "
53
+ method = Elasticsearch ::API ::HTTP_POST
54
+ path = if _task_type && _inference_id
55
+ "_inference/#{ Utils . __listify ( _task_type ) } /#{ Utils . __listify ( _inference_id ) } "
56
+ else
57
+ "_inference/#{ Utils . __listify ( _inference_id ) } "
58
+ end
56
59
params = { }
57
60
58
61
Elasticsearch ::API ::Response . new (
0 commit comments