Skip to content

Commit 5f58a5b

Browse files
[8.18] [ML] Switching from _unified to _stream for the chat_completion task type (#210104) (#210110)
# Backport This will backport the following commits from `main` to `8.18`: - [[ML] Switching from _unified to _stream for the chat_completion task type (#210104)](#210104) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Jonathan Buttner","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-02-06T21:40:47Z","message":"[ML] Switching from _unified to _stream for the chat_completion task type (#210104)\n\nThis PR switch the endpoint used for the `chat_completion` task type to\r\n`_stream`. Only the URL changes, the request and response format stay\r\nthe same. The `_stream` URL was introduced a couple verisons ago and is\r\nthe preferred route for interacting with `chat_completion`.\r\n\r\n### Testing\r\n\r\nSetup a pre-configured connector for security. Add this to your\r\n`config/kibana.dev.yml`\r\n\r\n```\r\nxpack.actions.preconfigured:\r\n my-inference-open-ai:\r\n name: Inference Preconfig Jon\r\n actionTypeId: .inference\r\n exposeConfig: true\r\n config:\r\n provider: 'openai'\r\n taskType: 'chat_completion'\r\n inferenceId: 'openai-chat_completion-123'\r\n providerConfig:\r\n rate_limit:\r\n requests_per_minute: 80000\r\n model_id: 'gpt-4o'\r\n url: https://api.openai.com/v1/chat/completions\r\n secrets:\r\n providerSecrets:\r\n api_key: '<api key>'\r\n```\r\n\r\nThen via the Connectors page, create an AI connector with the inference\r\nendpoint id set to `openai-chat_completion-123`\r\n\r\n\r\nhttps://github.com/user-attachments/assets/29d56d58-cd96-432f-9d13-460446d204a1","sha":"3a14752dad189a9702be1f108b14680e7d1fe9bc","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:ML","Feature:GenAI","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[ML] Switching from _unified to _stream for the chat_completion task type","number":210104,"url":"https://github.com/elastic/kibana/pull/210104","mergeCommit":{"message":"[ML] Switching from _unified to _stream for the chat_completion task type (#210104)\n\nThis PR switch the endpoint used for the `chat_completion` task type to\r\n`_stream`. Only the URL changes, the request and response format stay\r\nthe same. The `_stream` URL was introduced a couple verisons ago and is\r\nthe preferred route for interacting with `chat_completion`.\r\n\r\n### Testing\r\n\r\nSetup a pre-configured connector for security. Add this to your\r\n`config/kibana.dev.yml`\r\n\r\n```\r\nxpack.actions.preconfigured:\r\n my-inference-open-ai:\r\n name: Inference Preconfig Jon\r\n actionTypeId: .inference\r\n exposeConfig: true\r\n config:\r\n provider: 'openai'\r\n taskType: 'chat_completion'\r\n inferenceId: 'openai-chat_completion-123'\r\n providerConfig:\r\n rate_limit:\r\n requests_per_minute: 80000\r\n model_id: 'gpt-4o'\r\n url: https://api.openai.com/v1/chat/completions\r\n secrets:\r\n providerSecrets:\r\n api_key: '<api key>'\r\n```\r\n\r\nThen via the Connectors page, create an AI connector with the inference\r\nendpoint id set to `openai-chat_completion-123`\r\n\r\n\r\nhttps://github.com/user-attachments/assets/29d56d58-cd96-432f-9d13-460446d204a1","sha":"3a14752dad189a9702be1f108b14680e7d1fe9bc"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210104","number":210104,"mergeCommit":{"message":"[ML] Switching from _unified to _stream for the chat_completion task type (#210104)\n\nThis PR switch the endpoint used for the `chat_completion` task type to\r\n`_stream`. Only the URL changes, the request and response format stay\r\nthe same. The `_stream` URL was introduced a couple verisons ago and is\r\nthe preferred route for interacting with `chat_completion`.\r\n\r\n### Testing\r\n\r\nSetup a pre-configured connector for security. Add this to your\r\n`config/kibana.dev.yml`\r\n\r\n```\r\nxpack.actions.preconfigured:\r\n my-inference-open-ai:\r\n name: Inference Preconfig Jon\r\n actionTypeId: .inference\r\n exposeConfig: true\r\n config:\r\n provider: 'openai'\r\n taskType: 'chat_completion'\r\n inferenceId: 'openai-chat_completion-123'\r\n providerConfig:\r\n rate_limit:\r\n requests_per_minute: 80000\r\n model_id: 'gpt-4o'\r\n url: https://api.openai.com/v1/chat/completions\r\n secrets:\r\n providerSecrets:\r\n api_key: '<api key>'\r\n```\r\n\r\nThen via the Connectors page, create an AI connector with the inference\r\nendpoint id set to `openai-chat_completion-123`\r\n\r\n\r\nhttps://github.com/user-attachments/assets/29d56d58-cd96-432f-9d13-460446d204a1","sha":"3a14752dad189a9702be1f108b14680e7d1fe9bc"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Jonathan Buttner <[email protected]>
1 parent b97ae80 commit 5f58a5b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

x-pack/platform/plugins/shared/stack_connectors/server/connector_types/inference/inference.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('InferenceConnector', () => {
8484
n: undefined,
8585
},
8686
method: 'POST',
87-
path: '_inference/chat_completion/test/_unified',
87+
path: '_inference/chat_completion/test/_stream',
8888
},
8989
{ asStream: true, meta: true }
9090
);
@@ -288,7 +288,7 @@ describe('InferenceConnector', () => {
288288
n: undefined,
289289
},
290290
method: 'POST',
291-
path: '_inference/chat_completion/test/_unified',
291+
path: '_inference/chat_completion/test/_stream',
292292
},
293293
{ asStream: true, meta: true }
294294
);
@@ -310,7 +310,7 @@ describe('InferenceConnector', () => {
310310
{
311311
body: { messages: [{ content: 'Hello world', role: 'user' }], n: undefined },
312312
method: 'POST',
313-
path: '_inference/chat_completion/test/_unified',
313+
path: '_inference/chat_completion/test/_stream',
314314
},
315315
{ asStream: true, meta: true, signal }
316316
);

x-pack/platform/plugins/shared/stack_connectors/server/connector_types/inference/inference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export class InferenceConnector extends SubActionConnector<Config, Secrets> {
187187
const response = await this.esClient.transport.request<UnifiedChatCompleteResponse>(
188188
{
189189
method: 'POST',
190-
path: `_inference/chat_completion/${this.inferenceId}/_unified`,
190+
path: `_inference/chat_completion/${this.inferenceId}/_stream`,
191191
body: { ...params.body, n: undefined }, // exclude n param for now, constant is used on the inference API side
192192
},
193193
{

0 commit comments

Comments
 (0)