Skip to content

Commit d21b6ed

Browse files
authored
Merge branch 'main' into renovate/ms-2.x
2 parents 6733107 + b9a2df5 commit d21b6ed

23 files changed

+332
-316
lines changed

docs/doc_examples/120fcf9f55128d6a81d5e87a9c235bbd.asciidoc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33

44
[source, js]
55
----
6-
const response = await client.inference.streamInference({
7-
task_type: "chat_completion",
6+
const response = await client.inference.chatCompletionUnified({
87
inference_id: "openai-completion",
9-
model: "gpt-4o",
10-
messages: [
11-
{
12-
role: "user",
13-
content: "What is Elastic?",
14-
},
15-
],
8+
chat_completion_request: {
9+
model: "gpt-4o",
10+
messages: [
11+
{
12+
role: "user",
13+
content: "What is Elastic?",
14+
},
15+
],
16+
},
1617
});
1718
console.log(response);
1819
----

docs/doc_examples/13ecdf99114098c76b050397d9c3d4e6.asciidoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
[source, js]
55
----
6-
const response = await client.inference.inference({
7-
task_type: "sparse_embedding",
6+
const response = await client.inference.sparseEmbedding({
87
inference_id: "my-elser-model",
98
input:
109
"The sky above the port was the color of television tuned to a dead channel.",

docs/doc_examples/141ef0ebaa3b0772892b79b9bb85efb0.asciidoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33

44
[source, js]
55
----
6-
const response = await client.inference.put({
7-
task_type: "my-inference-endpoint",
8-
inference_id: "_update",
6+
const response = await client.inference.update({
7+
inference_id: "my-inference-endpoint",
98
inference_config: {
109
service_settings: {
1110
api_key: "<API_KEY>",

docs/doc_examples/45954b8aaedfed57012be8b6538b0a24.asciidoc

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,43 @@
33

44
[source, js]
55
----
6-
const response = await client.inference.streamInference({
7-
task_type: "chat_completion",
6+
const response = await client.inference.chatCompletionUnified({
87
inference_id: "openai-completion",
9-
messages: [
10-
{
11-
role: "user",
12-
content: [
13-
{
14-
type: "text",
15-
text: "What's the price of a scarf?",
8+
chat_completion_request: {
9+
messages: [
10+
{
11+
role: "user",
12+
content: [
13+
{
14+
type: "text",
15+
text: "What's the price of a scarf?",
16+
},
17+
],
18+
},
19+
],
20+
tools: [
21+
{
22+
type: "function",
23+
function: {
24+
name: "get_current_price",
25+
description: "Get the current price of a item",
26+
parameters: {
27+
type: "object",
28+
properties: {
29+
item: {
30+
id: "123",
31+
},
32+
},
33+
},
1634
},
17-
],
18-
},
19-
],
20-
tools: [
21-
{
35+
},
36+
],
37+
tool_choice: {
2238
type: "function",
2339
function: {
2440
name: "get_current_price",
25-
description: "Get the current price of a item",
26-
parameters: {
27-
type: "object",
28-
properties: {
29-
item: {
30-
id: "123",
31-
},
32-
},
33-
},
3441
},
3542
},
36-
],
37-
tool_choice: {
38-
type: "function",
39-
function: {
40-
name: "get_current_price",
41-
},
4243
},
4344
});
4445
console.log(response);

docs/doc_examples/4b91ad7c9b44e07db4a4e81390f19ad3.asciidoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
[source, js]
55
----
6-
const response = await client.inference.streamInference({
7-
task_type: "completion",
6+
const response = await client.inference.streamCompletion({
87
inference_id: "openai-completion",
98
input: "What is Elastic?",
109
});

docs/doc_examples/7429b16221fe741fd31b0584786dd0b0.asciidoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
[source, js]
55
----
6-
const response = await client.inference.inference({
7-
task_type: "text_embedding",
6+
const response = await client.inference.textEmbedding({
87
inference_id: "my-cohere-endpoint",
98
input:
109
"The sky above the port was the color of television tuned to a dead channel.",

docs/doc_examples/82bb6c61dab959f4446dc5ecab7ecbdf.asciidoc

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,31 @@
33

44
[source, js]
55
----
6-
const response = await client.inference.streamInference({
7-
task_type: "chat_completion",
6+
const response = await client.inference.chatCompletionUnified({
87
inference_id: "openai-completion",
9-
messages: [
10-
{
11-
role: "assistant",
12-
content: "Let's find out what the weather is",
13-
tool_calls: [
14-
{
15-
id: "call_KcAjWtAww20AihPHphUh46Gd",
16-
type: "function",
17-
function: {
18-
name: "get_current_weather",
19-
arguments: '{"location":"Boston, MA"}',
8+
chat_completion_request: {
9+
messages: [
10+
{
11+
role: "assistant",
12+
content: "Let's find out what the weather is",
13+
tool_calls: [
14+
{
15+
id: "call_KcAjWtAww20AihPHphUh46Gd",
16+
type: "function",
17+
function: {
18+
name: "get_current_weather",
19+
arguments: '{"location":"Boston, MA"}',
20+
},
2021
},
21-
},
22-
],
23-
},
24-
{
25-
role: "tool",
26-
content: "The weather is cold",
27-
tool_call_id: "call_KcAjWtAww20AihPHphUh46Gd",
28-
},
29-
],
22+
],
23+
},
24+
{
25+
role: "tool",
26+
content: "The weather is cold",
27+
tool_call_id: "call_KcAjWtAww20AihPHphUh46Gd",
28+
},
29+
],
30+
},
3031
});
3132
console.log(response);
3233
----

docs/doc_examples/b45a8c6fc746e9c90fd181e69a605fad.asciidoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
[source, js]
55
----
6-
const response = await client.inference.inference({
7-
task_type: "completion",
6+
const response = await client.inference.completion({
87
inference_id: "openai_chat_completions",
98
input: "What is Elastic?",
109
});

docs/doc_examples/f1b24217b1d9ba6ea5e4fa6e6f412022.asciidoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33

44
[source, js]
55
----
6-
const response = await client.inference.inference({
7-
task_type: "rerank",
6+
const response = await client.inference.rerank({
87
inference_id: "cohere_rerank",
98
input: ["luke", "like", "leia", "chewy", "r2d2", "star", "wars"],
109
query: "star wars main character",

docs/reference/api-reference.md

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7553,23 +7553,6 @@ client.inference.get({ ... })
75537553
- **`task_type` (Optional, Enum("sparse_embedding" | "text_embedding" | "rerank" | "completion" | "chat_completion"))**: The task type
75547554
- **`inference_id` (Optional, string)**: The inference Id
75557555

7556-
## client.inference.postEisChatCompletion [_inference.post_eis_chat_completion]
7557-
Perform a chat completion task through the Elastic Inference Service (EIS).
7558-
7559-
Perform a chat completion inference task with the `elastic` service.
7560-
7561-
[Endpoint documentation](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-post-eis-chat-completion)
7562-
7563-
```ts
7564-
client.inference.postEisChatCompletion({ eis_inference_id })
7565-
```
7566-
7567-
### Arguments [_arguments_inference.post_eis_chat_completion]
7568-
7569-
#### Request (object) [_request_inference.post_eis_chat_completion]
7570-
- **`eis_inference_id` (string)**: The unique identifier of the inference endpoint.
7571-
- **`chat_completion_request` (Optional, { messages, model, max_completion_tokens, stop, temperature, tool_choice, tools, top_p })**
7572-
75737556
## client.inference.put [_inference.put]
75747557
Create an inference endpoint.
75757558
When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
@@ -7776,26 +7759,6 @@ These settings are specific to the `cohere` service.
77767759
- **`task_settings` (Optional, { input_type, return_documents, top_n, truncate })**: Settings to configure the inference task.
77777760
These settings are specific to the task type you specified.
77787761

7779-
## client.inference.putEis [_inference.put_eis]
7780-
Create an Elastic Inference Service (EIS) inference endpoint.
7781-
7782-
Create an inference endpoint to perform an inference task through the Elastic Inference Service (EIS).
7783-
7784-
[Endpoint documentation](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-eis)
7785-
7786-
```ts
7787-
client.inference.putEis({ task_type, eis_inference_id, service, service_settings })
7788-
```
7789-
7790-
### Arguments [_arguments_inference.put_eis]
7791-
7792-
#### Request (object) [_request_inference.put_eis]
7793-
- **`task_type` (Enum("chat_completion"))**: The type of the inference task that the model will perform.
7794-
NOTE: The `chat_completion` task type only supports streaming and only through the _stream API.
7795-
- **`eis_inference_id` (string)**: The unique identifier of the inference endpoint.
7796-
- **`service` (Enum("elastic"))**: The type of service supported for the specified task type. In this case, `elastic`.
7797-
- **`service_settings` ({ model_id, rate_limit })**: Settings used to install the inference model. These settings are specific to the `elastic` service.
7798-
77997762
## client.inference.putElasticsearch [_inference.put_elasticsearch]
78007763
Create an Elasticsearch inference endpoint.
78017764

@@ -13567,8 +13530,6 @@ Multi-target syntax is supported.
1356713530
- **`master_timeout` (Optional, string | -1 | 0)**: The period to wait for the master node.
1356813531
If the master node is not available before the timeout expires, the request fails and returns an error.
1356913532
To indicate that the request should never timeout, set it to `-1`.
13570-
- **`timeout` (Optional, string | -1 | 0)**: The period of time to wait for a response.
13571-
If no response is received before the timeout expires, the request fails and returns an error.
1357213533

1357313534
## client.snapshot.create [_snapshot.create]
1357413535
Create a snapshot.

docs/reference/configuration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ The client is designed to be easily configured for your needs. In the following
99

1010
- [Basic configuration](/reference/basic-config.md)
1111
- [Advanced configuration](/reference/advanced-config.md)
12-
- [Timeout best practices](docs-content://troubleshoot/elasticsearch/elasticsearch-client-javascript-api/nodejs.md)
12+
- [Timeout best practices](/reference/timeout-best-practices.md)
1313
- [Creating a child client](/reference/child.md)
14-
- [Testing](/reference/client-testing.md)
14+
- [Testing](/reference/client-testing.md)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
mapped_pages:
3+
- https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/timeout-best-practices.html
4+
---
5+
6+
# Timeout best practices [timeout-best-practices]
7+
8+
Starting in 9.0.0, this client is configured to not time out any HTTP request by default. {{es}} will always eventually respond to any request, even if it takes several minutes. Reissuing a request that it has not responded to yet can cause performance side effects. See the [official {{es}} recommendations for HTTP clients](elasticsearch://reference/elasticsearch/configuration-reference/networking-settings.md#_http_client_configuration) for more information.
9+
10+
Prior to 9.0, this client was configured by default to operate like many HTTP client libraries do, by using a relatively short (30 second) timeout on all requests sent to {{es}}, raising a `TimeoutError` when that time period elapsed without receiving a response.
11+
12+
If you need to set timeouts on Elasticsearch requests, setting the `requestTimeout` value to a millisecond value will cause this client to operate as it did prior to 9.0.
13+

docs/reference/toc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ toc:
3131
- file: update_examples.md
3232
- file: update_by_query_examples.md
3333
- file: reindex_examples.md
34-
- file: client-helpers.md
34+
- file: client-helpers.md
35+
- file: timeout-best-practices.md

docs/release-notes/breaking-changes.md

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,53 @@ navigation_title: "Breaking changes"
33
---
44

55
# Elasticsearch JavaScript Client breaking changes [elasticsearch-javascript-client-breaking-changes]
6+
67
Breaking changes can impact your Elastic applications, potentially disrupting normal operations. Before you upgrade, carefully review the Elasticsearch JavaScript Client breaking changes and take the necessary steps to mitigate any issues. To learn how to upgrade, check [Upgrade](docs-content://deploy-manage/upgrade.md).
78

89
% ## Next version [elasticsearch-javascript-client-versionnext-breaking-changes]
910

10-
% ::::{dropdown} Title of breaking change
11+
% ::::{dropdown} Title of breaking change
1112
% Description of the breaking change.
1213
% For more information, check [PR #](PR link).
1314
% **Impact**<br> Impact of the breaking change.
1415
% **Action**<br> Steps for mitigating deprecation impact.
1516
% ::::
1617

17-
% ## 9.0.0 [elasticsearch-javascript-client-900-breaking-changes]
18+
## 9.0.0 [elasticsearch-javascript-client-900-breaking-changes]
1819

19-
% ::::{dropdown} Title of breaking change
20-
% Description of the breaking change.
21-
% For more information, check [PR #](PR link).
22-
% **Impact**<br> Impact of the breaking change.
23-
% **Action**<br> Steps for mitigating deprecation impact.
24-
% ::::
20+
::::{dropdown} Changes to the optional body property
21+
22+
In 8.x, every API function had a `body` property that would provide a place to put arbitrary values that should go in the HTTP request body, even if they were not noted in the specification or documentation. In 9.0, each API function still includes an optional `body` property, but TypeScript's type checker will disallow properties that should go in the root of the object. A `querystring` parameter has also been added that behaves the same as `body`, but inserts its values into the request querystring.
23+
24+
**Impact**<br> Some adjustments to API calls may be necessary for code that used a `body` property 8.x, especially to appease the TypeScript type checker, but it should not have any impact on any code that was not using a `body` property.
25+
26+
**Action**<br> Check existing code for use of the `body` property, and move any properties that should be in the root object according to the API function's request type definition. If using TypeScript, the TypeScript type checker will surface most of these issues for you.
27+
::::
28+
29+
::::{dropdown} Changes to API parameter collation into an HTTP request
30+
31+
The logic for where each parameter in an API function call should be added to its HTTP request has been updated:
32+
33+
1. If recognized as a `body` parameter according to the Elasticsearch specification, put it in the JSON body
34+
2. If recognized as a `path` parameter, put it in the URL path
35+
3. If recognized as a `query` parameter or a "common" query parameter (e.g. `pretty`, `error_trace`), put it in the querystring
36+
4. If not recognized, and this API accepts a JSON body, put it in the JSON body
37+
5. If not recognized and this API does not accept a JSON body, put it in the querystring
38+
39+
The first two steps are identical in 8.x. The final three steps replace the logic from 8.x that put all unrecognized parameters in the querystring.
40+
41+
**Impact**<br> Some parameters that were sent via querystring to Elasticsearch may be sent in the JSON request body, and vice versa.
42+
43+
**Action**<br> If Elasticsearch sends back an error response due to a request not being valid, verify with the client's TypeScript type definitions, or via the docs, that the parameters your code passes are correct.
44+
::::
45+
46+
::::{dropdown} Removal of the default 30-second timeout on all API calls
47+
48+
The default 30-second timeout on all HTTP requests sent to Elasticsearch has been dropped in favor of having no timeout set at all. The previous behavior still works as it did when setting the `requestTimeout` value.
49+
50+
See pull request [#2573](https://github.com/elastic/elasticsearch-js/pull/2573) for more information.
51+
52+
**Impact**<br> Requests to Elasticsearch that used to time out after 30 seconds will now wait for as long as it takes for Elasticsearch to respond.
53+
54+
**Action**<br> In environments where it is not ideal to wait for an API response indefinitely, manually setting the `requestTimeout` option when instantiating the client still works as it did in 8.x.
55+
::::

docs/release-notes/deprecations.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@ navigation_title: "Deprecations"
55
# Elasticsearch JavaScript Client deprecations [elasticsearch-javascript-client-deprecations]
66
Over time, certain Elastic functionality becomes outdated and is replaced or removed. To help with the transition, Elastic deprecates functionality for a period before removal, giving you time to update your applications.
77

8-
Review the deprecated functionality for Elasticsearch JavaScript Client. While deprecations have no immediate impact, we strongly encourage you update your implementation after you upgrade. To learn how to upgrade, check out [Upgrade](docs-content://deploy-manage/upgrade.md).
8+
Review the deprecated functionality for the Elasticsearch JavaScript Client. While deprecations have no immediate impact, we strongly encourage you update your implementation after you upgrade. To learn how to upgrade, check out [Upgrade](docs-content://deploy-manage/upgrade.md).
99

10-
% ## Next version
10+
## 9.0.0 [elasticsearch-javascript-client-900-deprecations]
1111

12-
% ::::{dropdown} Deprecation title
13-
% Description of the deprecation.
14-
% For more information, check [PR #](PR link).
15-
% **Impact**<br> Impact of deprecation.
16-
% **Action**<br> Steps for mitigating deprecation impact.
17-
% ::::
12+
_No deprecations_
1813

19-
% ## 9.0.0 [elasticsearch-javascript-client-900-deprecations]
14+
% ## Next version
2015

2116
% ::::{dropdown} Deprecation title
2217
% Description of the deprecation.

0 commit comments

Comments
 (0)