Skip to content

Auto-generated code for main #2847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions elasticsearch/_async/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,12 +1008,17 @@ async def create(
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
if_primary_term: t.Optional[int] = None,
if_seq_no: t.Optional[int] = None,
include_source_on_error: t.Optional[bool] = None,
op_type: t.Optional[t.Union[str, t.Literal["create", "index"]]] = None,
pipeline: t.Optional[str] = None,
pretty: t.Optional[bool] = None,
refresh: t.Optional[
t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
] = None,
require_alias: t.Optional[bool] = None,
require_data_stream: t.Optional[bool] = None,
routing: t.Optional[str] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
version: t.Optional[int] = None,
Expand Down Expand Up @@ -1091,8 +1096,18 @@ async def create(
:param id: A unique identifier for the document. To automatically generate a
document ID, use the `POST /<target>/_doc/` request format.
:param document:
:param if_primary_term: Only perform the operation if the document has this primary
term.
:param if_seq_no: Only perform the operation if the document has this sequence
number.
:param include_source_on_error: True or false if to include the document source
in the error message in case of parsing errors.
:param op_type: Set to `create` to only index the document if it does not already
exist (put if absent). If a document with the specified `_id` already exists,
the indexing operation will fail. The behavior is the same as using the `<index>/_create`
endpoint. If a document ID is specified, this paramater defaults to `index`.
Otherwise, it defaults to `create`. If the request targets a data stream,
an `op_type` of `create` is required.
:param pipeline: The ID of the pipeline to use to preprocess incoming documents.
If the index has a default ingest pipeline specified, setting the value to
`_none` turns off the default ingest pipeline for this request. If a final
Expand All @@ -1101,6 +1116,9 @@ async def create(
:param refresh: If `true`, Elasticsearch refreshes the affected shards to make
this operation visible to search. If `wait_for`, it waits for a refresh to
make this operation visible to search. If `false`, it does nothing with refreshes.
:param require_alias: If `true`, the destination must be an index alias.
:param require_data_stream: If `true`, the request's actions must target a data
stream (existing or to be created).
:param routing: A custom value that is used to route operations to a specific
shard.
:param timeout: The period the request waits for the following operations: automatic
Expand Down Expand Up @@ -1141,14 +1159,24 @@ async def create(
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if if_primary_term is not None:
__query["if_primary_term"] = if_primary_term
if if_seq_no is not None:
__query["if_seq_no"] = if_seq_no
if include_source_on_error is not None:
__query["include_source_on_error"] = include_source_on_error
if op_type is not None:
__query["op_type"] = op_type
if pipeline is not None:
__query["pipeline"] = pipeline
if pretty is not None:
__query["pretty"] = pretty
if refresh is not None:
__query["refresh"] = refresh
if require_alias is not None:
__query["require_alias"] = require_alias
if require_data_stream is not None:
__query["require_data_stream"] = require_data_stream
if routing is not None:
__query["routing"] = routing
if timeout is not None:
Expand Down
102 changes: 100 additions & 2 deletions elasticsearch/_async/client/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,104 @@ async def put(
path_parts=__path_parts,
)

@_rewrite_parameters(
body_fields=(
"service",
"service_settings",
"chunking_settings",
"task_settings",
),
)
async def put_openai(
self,
*,
task_type: t.Union[
str, t.Literal["chat_completion", "completion", "text_embedding"]
],
openai_inference_id: str,
service: t.Optional[t.Union[str, t.Literal["openai"]]] = None,
service_settings: t.Optional[t.Mapping[str, t.Any]] = None,
chunking_settings: t.Optional[t.Mapping[str, t.Any]] = None,
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
pretty: t.Optional[bool] = None,
task_settings: t.Optional[t.Mapping[str, t.Any]] = None,
body: t.Optional[t.Dict[str, t.Any]] = None,
) -> ObjectApiResponse[t.Any]:
"""
.. raw:: html

<p>Create an OpenAI inference endpoint.</p>
<p>Create an inference endpoint to perform an inference task with the <code>openai</code> service.</p>
<p>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 <code>&quot;state&quot;: &quot;fully_allocated&quot;</code> in the response and ensure that the <code>&quot;allocation_count&quot;</code> matches the <code>&quot;target_allocation_count&quot;</code>.
Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/infer-service-openai.html>`_

:param 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.
:param openai_inference_id: The unique identifier of the inference endpoint.
:param service: The type of service supported for the specified task type. In
this case, `openai`.
:param service_settings: Settings used to install the inference model. These
settings are specific to the `openai` service.
:param chunking_settings: The chunking configuration object.
:param task_settings: Settings to configure the inference task. These settings
are specific to the task type you specified.
"""
if task_type in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'task_type'")
if openai_inference_id in SKIP_IN_PATH:
raise ValueError("Empty value passed for parameter 'openai_inference_id'")
if service is None and body is None:
raise ValueError("Empty value passed for parameter 'service'")
if service_settings is None and body is None:
raise ValueError("Empty value passed for parameter 'service_settings'")
__path_parts: t.Dict[str, str] = {
"task_type": _quote(task_type),
"openai_inference_id": _quote(openai_inference_id),
}
__path = f'/_inference/{__path_parts["task_type"]}/{__path_parts["openai_inference_id"]}'
__query: t.Dict[str, t.Any] = {}
__body: t.Dict[str, t.Any] = body if body is not None else {}
if error_trace is not None:
__query["error_trace"] = error_trace
if filter_path is not None:
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if pretty is not None:
__query["pretty"] = pretty
if not __body:
if service is not None:
__body["service"] = service
if service_settings is not None:
__body["service_settings"] = service_settings
if chunking_settings is not None:
__body["chunking_settings"] = chunking_settings
if task_settings is not None:
__body["task_settings"] = task_settings
if not __body:
__body = None # type: ignore[assignment]
__headers = {"accept": "application/json"}
if __body is not None:
__headers["content-type"] = "application/json"
return await self.perform_request( # type: ignore[return-value]
"PUT",
__path,
params=__query,
headers=__headers,
body=__body,
endpoint_id="inference.put_openai",
path_parts=__path_parts,
)

@_rewrite_parameters(
body_fields=("service", "service_settings"),
)
Expand All @@ -341,7 +439,7 @@ async def put_watsonx(
.. raw:: html

<p>Create a Watsonx inference endpoint.</p>
<p>Creates an inference endpoint to perform an inference task with the <code>watsonxai</code> service.
<p>Create an inference endpoint to perform an inference task with the <code>watsonxai</code> service.
You need an IBM Cloud Databases for Elasticsearch deployment to use the <code>watsonxai</code> inference service.
You can provision one through the IBM catalog, the Cloud Databases CLI plug-in, the Cloud Databases API, or Terraform.</p>
<p>When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
Expand All @@ -351,7 +449,7 @@ async def put_watsonx(
Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.</p>


`<https://www.elastic.co/guide/en/elasticsearch/reference/master/infer-service-watsonx-ai.html>`_
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-watsonx>`_

:param task_type: The task type. The only valid task type for the model to perform
is `text_embedding`.
Expand Down
8 changes: 4 additions & 4 deletions elasticsearch/_async/client/ml.py
Original file line number Diff line number Diff line change
Expand Up @@ -3599,11 +3599,11 @@ async def put_datafeed(
:param ignore_unavailable: If true, unavailable indices (missing or closed) are
ignored.
:param indexes: An array of index names. Wildcards are supported. If any of the
indices are in remote clusters, the machine learning nodes must have the
`remote_cluster_client` role.
indices are in remote clusters, the master nodes and the machine learning
nodes must have the `remote_cluster_client` role.
:param indices: An array of index names. Wildcards are supported. If any of the
indices are in remote clusters, the machine learning nodes must have the
`remote_cluster_client` role.
indices are in remote clusters, the master nodes and the machine learning
nodes must have the `remote_cluster_client` role.
:param indices_options: Specifies index expansion options that are used during
search
:param job_id: Identifier for the anomaly detection job.
Expand Down
28 changes: 28 additions & 0 deletions elasticsearch/_sync/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1006,12 +1006,17 @@ def create(
error_trace: t.Optional[bool] = None,
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
human: t.Optional[bool] = None,
if_primary_term: t.Optional[int] = None,
if_seq_no: t.Optional[int] = None,
include_source_on_error: t.Optional[bool] = None,
op_type: t.Optional[t.Union[str, t.Literal["create", "index"]]] = None,
pipeline: t.Optional[str] = None,
pretty: t.Optional[bool] = None,
refresh: t.Optional[
t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
] = None,
require_alias: t.Optional[bool] = None,
require_data_stream: t.Optional[bool] = None,
routing: t.Optional[str] = None,
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
version: t.Optional[int] = None,
Expand Down Expand Up @@ -1089,8 +1094,18 @@ def create(
:param id: A unique identifier for the document. To automatically generate a
document ID, use the `POST /<target>/_doc/` request format.
:param document:
:param if_primary_term: Only perform the operation if the document has this primary
term.
:param if_seq_no: Only perform the operation if the document has this sequence
number.
:param include_source_on_error: True or false if to include the document source
in the error message in case of parsing errors.
:param op_type: Set to `create` to only index the document if it does not already
exist (put if absent). If a document with the specified `_id` already exists,
the indexing operation will fail. The behavior is the same as using the `<index>/_create`
endpoint. If a document ID is specified, this paramater defaults to `index`.
Otherwise, it defaults to `create`. If the request targets a data stream,
an `op_type` of `create` is required.
:param pipeline: The ID of the pipeline to use to preprocess incoming documents.
If the index has a default ingest pipeline specified, setting the value to
`_none` turns off the default ingest pipeline for this request. If a final
Expand All @@ -1099,6 +1114,9 @@ def create(
:param refresh: If `true`, Elasticsearch refreshes the affected shards to make
this operation visible to search. If `wait_for`, it waits for a refresh to
make this operation visible to search. If `false`, it does nothing with refreshes.
:param require_alias: If `true`, the destination must be an index alias.
:param require_data_stream: If `true`, the request's actions must target a data
stream (existing or to be created).
:param routing: A custom value that is used to route operations to a specific
shard.
:param timeout: The period the request waits for the following operations: automatic
Expand Down Expand Up @@ -1139,14 +1157,24 @@ def create(
__query["filter_path"] = filter_path
if human is not None:
__query["human"] = human
if if_primary_term is not None:
__query["if_primary_term"] = if_primary_term
if if_seq_no is not None:
__query["if_seq_no"] = if_seq_no
if include_source_on_error is not None:
__query["include_source_on_error"] = include_source_on_error
if op_type is not None:
__query["op_type"] = op_type
if pipeline is not None:
__query["pipeline"] = pipeline
if pretty is not None:
__query["pretty"] = pretty
if refresh is not None:
__query["refresh"] = refresh
if require_alias is not None:
__query["require_alias"] = require_alias
if require_data_stream is not None:
__query["require_data_stream"] = require_data_stream
if routing is not None:
__query["routing"] = routing
if timeout is not None:
Expand Down
Loading