@@ -29,8 +29,10 @@ class InferenceClient(NamespacedClient):
29
29
async def delete_model (
30
30
self ,
31
31
* ,
32
- task_type : t .Union ["t.Literal['sparse_embedding', 'text_embedding']" , str ],
33
- model_id : str ,
32
+ inference_id : str ,
33
+ task_type : t .Optional [
34
+ t .Union ["t.Literal['sparse_embedding', 'text_embedding']" , str ]
35
+ ] = None ,
34
36
error_trace : t .Optional [bool ] = None ,
35
37
filter_path : t .Optional [t .Union [str , t .Sequence [str ]]] = None ,
36
38
human : t .Optional [bool ] = None ,
@@ -41,14 +43,17 @@ async def delete_model(
41
43
42
44
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/delete-inference-api.html>`_
43
45
44
- :param task_type : The model task type
45
- :param model_id : The unique identifier of the inference model.
46
+ :param inference_id : The inference Id
47
+ :param task_type : The task type
46
48
"""
47
- if task_type in SKIP_IN_PATH :
48
- raise ValueError ("Empty value passed for parameter 'task_type'" )
49
- if model_id in SKIP_IN_PATH :
50
- raise ValueError ("Empty value passed for parameter 'model_id'" )
51
- __path = f"/_inference/{ _quote (task_type )} /{ _quote (model_id )} "
49
+ if inference_id in SKIP_IN_PATH :
50
+ raise ValueError ("Empty value passed for parameter 'inference_id'" )
51
+ if task_type not in SKIP_IN_PATH and inference_id not in SKIP_IN_PATH :
52
+ __path = f"/_inference/{ _quote (task_type )} /{ _quote (inference_id )} "
53
+ elif inference_id not in SKIP_IN_PATH :
54
+ __path = f"/_inference/{ _quote (inference_id )} "
55
+ else :
56
+ raise ValueError ("Couldn't find a path for the given parameters" )
52
57
__query : t .Dict [str , t .Any ] = {}
53
58
if error_trace is not None :
54
59
__query ["error_trace" ] = error_trace
@@ -67,8 +72,10 @@ async def delete_model(
67
72
async def get_model (
68
73
self ,
69
74
* ,
70
- task_type : t .Union ["t.Literal['sparse_embedding', 'text_embedding']" , str ],
71
- model_id : str ,
75
+ inference_id : str ,
76
+ task_type : t .Optional [
77
+ t .Union ["t.Literal['sparse_embedding', 'text_embedding']" , str ]
78
+ ] = None ,
72
79
error_trace : t .Optional [bool ] = None ,
73
80
filter_path : t .Optional [t .Union [str , t .Sequence [str ]]] = None ,
74
81
human : t .Optional [bool ] = None ,
@@ -79,14 +86,17 @@ async def get_model(
79
86
80
87
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-inference-api.html>`_
81
88
82
- :param task_type : The model task type
83
- :param model_id : The unique identifier of the inference model.
89
+ :param inference_id : The inference Id
90
+ :param task_type : The task type
84
91
"""
85
- if task_type in SKIP_IN_PATH :
86
- raise ValueError ("Empty value passed for parameter 'task_type'" )
87
- if model_id in SKIP_IN_PATH :
88
- raise ValueError ("Empty value passed for parameter 'model_id'" )
89
- __path = f"/_inference/{ _quote (task_type )} /{ _quote (model_id )} "
92
+ if inference_id in SKIP_IN_PATH :
93
+ raise ValueError ("Empty value passed for parameter 'inference_id'" )
94
+ if task_type not in SKIP_IN_PATH and inference_id not in SKIP_IN_PATH :
95
+ __path = f"/_inference/{ _quote (task_type )} /{ _quote (inference_id )} "
96
+ elif inference_id not in SKIP_IN_PATH :
97
+ __path = f"/_inference/{ _quote (inference_id )} "
98
+ else :
99
+ raise ValueError ("Couldn't find a path for the given parameters" )
90
100
__query : t .Dict [str , t .Any ] = {}
91
101
if error_trace is not None :
92
102
__query ["error_trace" ] = error_trace
@@ -107,9 +117,11 @@ async def get_model(
107
117
async def inference (
108
118
self ,
109
119
* ,
110
- task_type : t .Union ["t.Literal['sparse_embedding', 'text_embedding']" , str ],
111
- model_id : str ,
120
+ inference_id : str ,
112
121
input : t .Optional [t .Union [str , t .Sequence [str ]]] = None ,
122
+ task_type : t .Optional [
123
+ t .Union ["t.Literal['sparse_embedding', 'text_embedding']" , str ]
124
+ ] = None ,
113
125
error_trace : t .Optional [bool ] = None ,
114
126
filter_path : t .Optional [t .Union [str , t .Sequence [str ]]] = None ,
115
127
human : t .Optional [bool ] = None ,
@@ -122,18 +134,21 @@ async def inference(
122
134
123
135
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/post-inference-api.html>`_
124
136
125
- :param task_type: The model task type
126
- :param model_id: The unique identifier of the inference model.
137
+ :param inference_id: The inference Id
127
138
:param input: Text input to the model. Either a string or an array of strings.
139
+ :param task_type: The task type
128
140
:param task_settings: Optional task settings
129
141
"""
130
- if task_type in SKIP_IN_PATH :
131
- raise ValueError ("Empty value passed for parameter 'task_type'" )
132
- if model_id in SKIP_IN_PATH :
133
- raise ValueError ("Empty value passed for parameter 'model_id'" )
142
+ if inference_id in SKIP_IN_PATH :
143
+ raise ValueError ("Empty value passed for parameter 'inference_id'" )
134
144
if input is None and body is None :
135
145
raise ValueError ("Empty value passed for parameter 'input'" )
136
- __path = f"/_inference/{ _quote (task_type )} /{ _quote (model_id )} "
146
+ if task_type not in SKIP_IN_PATH and inference_id not in SKIP_IN_PATH :
147
+ __path = f"/_inference/{ _quote (task_type )} /{ _quote (inference_id )} "
148
+ elif inference_id not in SKIP_IN_PATH :
149
+ __path = f"/_inference/{ _quote (inference_id )} "
150
+ else :
151
+ raise ValueError ("Couldn't find a path for the given parameters" )
137
152
__query : t .Dict [str , t .Any ] = {}
138
153
__body : t .Dict [str , t .Any ] = body if body is not None else {}
139
154
if error_trace is not None :
@@ -164,8 +179,10 @@ async def inference(
164
179
async def put_model (
165
180
self ,
166
181
* ,
167
- task_type : t .Union ["t.Literal['sparse_embedding', 'text_embedding']" , str ],
168
- model_id : str ,
182
+ inference_id : str ,
183
+ task_type : t .Optional [
184
+ t .Union ["t.Literal['sparse_embedding', 'text_embedding']" , str ]
185
+ ] = None ,
169
186
error_trace : t .Optional [bool ] = None ,
170
187
filter_path : t .Optional [t .Union [str , t .Sequence [str ]]] = None ,
171
188
human : t .Optional [bool ] = None ,
@@ -178,21 +195,24 @@ async def put_model(
178
195
179
196
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/put-inference-api.html>`_
180
197
181
- :param task_type : The model task type
182
- :param model_id : The unique identifier of the inference model.
198
+ :param inference_id : The inference Id
199
+ :param task_type : The task type
183
200
:param model_config:
184
201
"""
185
- if task_type in SKIP_IN_PATH :
186
- raise ValueError ("Empty value passed for parameter 'task_type'" )
187
- if model_id in SKIP_IN_PATH :
188
- raise ValueError ("Empty value passed for parameter 'model_id'" )
202
+ if inference_id in SKIP_IN_PATH :
203
+ raise ValueError ("Empty value passed for parameter 'inference_id'" )
189
204
if model_config is None and body is None :
190
205
raise ValueError (
191
206
"Empty value passed for parameters 'model_config' and 'body', one of them should be set."
192
207
)
193
208
elif model_config is not None and body is not None :
194
209
raise ValueError ("Cannot set both 'model_config' and 'body'" )
195
- __path = f"/_inference/{ _quote (task_type )} /{ _quote (model_id )} "
210
+ if task_type not in SKIP_IN_PATH and inference_id not in SKIP_IN_PATH :
211
+ __path = f"/_inference/{ _quote (task_type )} /{ _quote (inference_id )} "
212
+ elif inference_id not in SKIP_IN_PATH :
213
+ __path = f"/_inference/{ _quote (inference_id )} "
214
+ else :
215
+ raise ValueError ("Couldn't find a path for the given parameters" )
196
216
__query : t .Dict [str , t .Any ] = {}
197
217
if error_trace is not None :
198
218
__query ["error_trace" ] = error_trace
0 commit comments