From ce4acd37ffe73a105009bad7dcd0f7a344fe7bd4 Mon Sep 17 00:00:00 2001 From: Elastic Machine Date: Mon, 7 Apr 2025 21:31:00 +0200 Subject: [PATCH] Auto-generated API code (#2707) --- .../120fcf9f55128d6a81d5e87a9c235bbd.asciidoc | 19 +++--- .../13ecdf99114098c76b050397d9c3d4e6.asciidoc | 3 +- .../45954b8aaedfed57012be8b6538b0a24.asciidoc | 61 ++++++++++--------- .../4b91ad7c9b44e07db4a4e81390f19ad3.asciidoc | 3 +- .../7429b16221fe741fd31b0584786dd0b0.asciidoc | 3 +- .../82bb6c61dab959f4446dc5ecab7ecbdf.asciidoc | 45 +++++++------- .../b45a8c6fc746e9c90fd181e69a605fad.asciidoc | 3 +- .../f1b24217b1d9ba6ea5e4fa6e6f412022.asciidoc | 3 +- 8 files changed, 69 insertions(+), 71 deletions(-) diff --git a/docs/doc_examples/120fcf9f55128d6a81d5e87a9c235bbd.asciidoc b/docs/doc_examples/120fcf9f55128d6a81d5e87a9c235bbd.asciidoc index fbfd1cfc5..7c9de2841 100644 --- a/docs/doc_examples/120fcf9f55128d6a81d5e87a9c235bbd.asciidoc +++ b/docs/doc_examples/120fcf9f55128d6a81d5e87a9c235bbd.asciidoc @@ -3,16 +3,17 @@ [source, js] ---- -const response = await client.inference.streamInference({ - task_type: "chat_completion", +const response = await client.inference.chatCompletionUnified({ inference_id: "openai-completion", - model: "gpt-4o", - messages: [ - { - role: "user", - content: "What is Elastic?", - }, - ], + chat_completion_request: { + model: "gpt-4o", + messages: [ + { + role: "user", + content: "What is Elastic?", + }, + ], + }, }); console.log(response); ---- diff --git a/docs/doc_examples/13ecdf99114098c76b050397d9c3d4e6.asciidoc b/docs/doc_examples/13ecdf99114098c76b050397d9c3d4e6.asciidoc index 01baab9cf..cb18160a8 100644 --- a/docs/doc_examples/13ecdf99114098c76b050397d9c3d4e6.asciidoc +++ b/docs/doc_examples/13ecdf99114098c76b050397d9c3d4e6.asciidoc @@ -3,8 +3,7 @@ [source, js] ---- -const response = await client.inference.inference({ - task_type: "sparse_embedding", +const response = await client.inference.sparseEmbedding({ inference_id: "my-elser-model", input: "The sky above the port was the color of television tuned to a dead channel.", diff --git a/docs/doc_examples/45954b8aaedfed57012be8b6538b0a24.asciidoc b/docs/doc_examples/45954b8aaedfed57012be8b6538b0a24.asciidoc index 4d6846969..12fb33095 100644 --- a/docs/doc_examples/45954b8aaedfed57012be8b6538b0a24.asciidoc +++ b/docs/doc_examples/45954b8aaedfed57012be8b6538b0a24.asciidoc @@ -3,41 +3,42 @@ [source, js] ---- -const response = await client.inference.streamInference({ - task_type: "chat_completion", +const response = await client.inference.chatCompletionUnified({ inference_id: "openai-completion", - messages: [ - { - role: "user", - content: [ - { - type: "text", - text: "What's the price of a scarf?", - }, - ], - }, - ], - tools: [ - { - type: "function", - function: { - name: "get_current_price", - description: "Get the current price of a item", - parameters: { - type: "object", - properties: { - item: { - id: "123", + chat_completion_request: { + messages: [ + { + role: "user", + content: [ + { + type: "text", + text: "What's the price of a scarf?", + }, + ], + }, + ], + tools: [ + { + type: "function", + function: { + name: "get_current_price", + description: "Get the current price of a item", + parameters: { + type: "object", + properties: { + item: { + id: "123", + }, }, }, }, }, - }, - ], - tool_choice: { - type: "function", - function: { - name: "get_current_price", + ], + tool_choice: { + type: "function", + function: { + name: "get_current_price", + }, }, }, }); diff --git a/docs/doc_examples/4b91ad7c9b44e07db4a4e81390f19ad3.asciidoc b/docs/doc_examples/4b91ad7c9b44e07db4a4e81390f19ad3.asciidoc index 9ae0176bc..1e6cd8582 100644 --- a/docs/doc_examples/4b91ad7c9b44e07db4a4e81390f19ad3.asciidoc +++ b/docs/doc_examples/4b91ad7c9b44e07db4a4e81390f19ad3.asciidoc @@ -3,8 +3,7 @@ [source, js] ---- -const response = await client.inference.streamInference({ - task_type: "completion", +const response = await client.inference.streamCompletion({ inference_id: "openai-completion", input: "What is Elastic?", }); diff --git a/docs/doc_examples/7429b16221fe741fd31b0584786dd0b0.asciidoc b/docs/doc_examples/7429b16221fe741fd31b0584786dd0b0.asciidoc index 8f897c69c..e41a7bf42 100644 --- a/docs/doc_examples/7429b16221fe741fd31b0584786dd0b0.asciidoc +++ b/docs/doc_examples/7429b16221fe741fd31b0584786dd0b0.asciidoc @@ -3,8 +3,7 @@ [source, js] ---- -const response = await client.inference.inference({ - task_type: "text_embedding", +const response = await client.inference.textEmbedding({ inference_id: "my-cohere-endpoint", input: "The sky above the port was the color of television tuned to a dead channel.", diff --git a/docs/doc_examples/82bb6c61dab959f4446dc5ecab7ecbdf.asciidoc b/docs/doc_examples/82bb6c61dab959f4446dc5ecab7ecbdf.asciidoc index 6958737be..c693e38f1 100644 --- a/docs/doc_examples/82bb6c61dab959f4446dc5ecab7ecbdf.asciidoc +++ b/docs/doc_examples/82bb6c61dab959f4446dc5ecab7ecbdf.asciidoc @@ -3,30 +3,31 @@ [source, js] ---- -const response = await client.inference.streamInference({ - task_type: "chat_completion", +const response = await client.inference.chatCompletionUnified({ inference_id: "openai-completion", - messages: [ - { - role: "assistant", - content: "Let's find out what the weather is", - tool_calls: [ - { - id: "call_KcAjWtAww20AihPHphUh46Gd", - type: "function", - function: { - name: "get_current_weather", - arguments: '{"location":"Boston, MA"}', + chat_completion_request: { + messages: [ + { + role: "assistant", + content: "Let's find out what the weather is", + tool_calls: [ + { + id: "call_KcAjWtAww20AihPHphUh46Gd", + type: "function", + function: { + name: "get_current_weather", + arguments: '{"location":"Boston, MA"}', + }, }, - }, - ], - }, - { - role: "tool", - content: "The weather is cold", - tool_call_id: "call_KcAjWtAww20AihPHphUh46Gd", - }, - ], + ], + }, + { + role: "tool", + content: "The weather is cold", + tool_call_id: "call_KcAjWtAww20AihPHphUh46Gd", + }, + ], + }, }); console.log(response); ---- diff --git a/docs/doc_examples/b45a8c6fc746e9c90fd181e69a605fad.asciidoc b/docs/doc_examples/b45a8c6fc746e9c90fd181e69a605fad.asciidoc index 876b182d2..0a14b2f32 100644 --- a/docs/doc_examples/b45a8c6fc746e9c90fd181e69a605fad.asciidoc +++ b/docs/doc_examples/b45a8c6fc746e9c90fd181e69a605fad.asciidoc @@ -3,8 +3,7 @@ [source, js] ---- -const response = await client.inference.inference({ - task_type: "completion", +const response = await client.inference.completion({ inference_id: "openai_chat_completions", input: "What is Elastic?", }); diff --git a/docs/doc_examples/f1b24217b1d9ba6ea5e4fa6e6f412022.asciidoc b/docs/doc_examples/f1b24217b1d9ba6ea5e4fa6e6f412022.asciidoc index 023d009ab..31cf0b9d3 100644 --- a/docs/doc_examples/f1b24217b1d9ba6ea5e4fa6e6f412022.asciidoc +++ b/docs/doc_examples/f1b24217b1d9ba6ea5e4fa6e6f412022.asciidoc @@ -3,8 +3,7 @@ [source, js] ---- -const response = await client.inference.inference({ - task_type: "rerank", +const response = await client.inference.rerank({ inference_id: "cohere_rerank", input: ["luke", "like", "leia", "chewy", "r2d2", "star", "wars"], query: "star wars main character",