-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[inference] add pre-bound versions of chatComplete
and output
APIs
#200568
[inference] add pre-bound versions of chatComplete
and output
APIs
#200568
Conversation
/ci |
/ci |
/ci |
/ci |
/ci |
/ci |
Pinging @elastic/appex-ai-infra (Team:AI Infra) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, I have a couple of comments for us to discuss. Great job with the docs and typings on this one too.
x-pack/plugins/inference/common/chat_complete/bind_chat_complete.ts
Outdated
Show resolved
Hide resolved
chatComplete
and output
APIschatComplete
and output
APIs
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Public APIs missing exports
Unknown metric groupsAPI count
History
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
@elasticmachine merge upstream |
Starting backport for target branches: 8.x |
elastic#200568) ## Summary Fix elastic#199084 Introduce pre-bound versions of the inference APIs. Accessing the bound versions can be done using the same `getClient` API, via an additional `bindTo` parameter: **without bindings** ```ts const inferenceClient = myStartDeps.inference.getClient({ request }); const chatResponse = inferenceClient.chatComplete({ connectorId: 'my-connector-id', functionCalling: 'simulated', messages: [{ role: MessageRole.User, content: 'Do something' }], }); ``` **with bindings** ```ts const inferenceClient = myStartDeps.inference.getClient({ request, bindTo: { connectorId: 'my-connector-id', functionCalling: 'simulated', } }); const chatResponse = inferenceClient.chatComplete({ messages: [{ role: MessageRole.User, content: 'Do something' }], }); ``` *Note: this is only done for the server-side, as there isn't much value in scoping APIs on the browser side in my opinion* --------- Co-authored-by: Elastic Machine <[email protected]> (cherry picked from commit 3c8f077)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…and `output` APIs (#200568) (#201028) # Backport This will backport the following commits from `main` to `8.x`: - [[inference] add pre-bound versions of `chatComplete` and `output` APIs (#200568)](#200568) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Pierre Gayvallet","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-20T19:09:11Z","message":"[inference] add pre-bound versions of `chatComplete` and `output` APIs (#200568)\n\n## Summary\r\n\r\nFix https://github.com/elastic/kibana/issues/199084\r\n\r\nIntroduce pre-bound versions of the inference APIs.\r\n\r\nAccessing the bound versions can be done using the same `getClient` API,\r\nvia an additional `bindTo` parameter:\r\n\r\n**without bindings**\r\n```ts\r\nconst inferenceClient = myStartDeps.inference.getClient({ request });\r\n\r\nconst chatResponse = inferenceClient.chatComplete({\r\n connectorId: 'my-connector-id',\r\n functionCalling: 'simulated',\r\n messages: [{ role: MessageRole.User, content: 'Do something' }],\r\n});\r\n```\r\n\r\n**with bindings**\r\n```ts\r\nconst inferenceClient = myStartDeps.inference.getClient({\r\n request,\r\n bindTo: {\r\n connectorId: 'my-connector-id',\r\n functionCalling: 'simulated',\r\n }\r\n});\r\n\r\nconst chatResponse = inferenceClient.chatComplete({\r\n messages: [{ role: MessageRole.User, content: 'Do something' }],\r\n});\r\n```\r\n\r\n*Note: this is only done for the server-side, as there isn't much value\r\nin scoping APIs on the browser side in my opinion*\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"3c8f0777f4a4563824d0fb1f545524bf4346e3a2","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","Team:AI Infra","v8.17.0"],"title":"[inference] add pre-bound versions of `chatComplete` and `output` APIs","number":200568,"url":"https://github.com/elastic/kibana/pull/200568","mergeCommit":{"message":"[inference] add pre-bound versions of `chatComplete` and `output` APIs (#200568)\n\n## Summary\r\n\r\nFix https://github.com/elastic/kibana/issues/199084\r\n\r\nIntroduce pre-bound versions of the inference APIs.\r\n\r\nAccessing the bound versions can be done using the same `getClient` API,\r\nvia an additional `bindTo` parameter:\r\n\r\n**without bindings**\r\n```ts\r\nconst inferenceClient = myStartDeps.inference.getClient({ request });\r\n\r\nconst chatResponse = inferenceClient.chatComplete({\r\n connectorId: 'my-connector-id',\r\n functionCalling: 'simulated',\r\n messages: [{ role: MessageRole.User, content: 'Do something' }],\r\n});\r\n```\r\n\r\n**with bindings**\r\n```ts\r\nconst inferenceClient = myStartDeps.inference.getClient({\r\n request,\r\n bindTo: {\r\n connectorId: 'my-connector-id',\r\n functionCalling: 'simulated',\r\n }\r\n});\r\n\r\nconst chatResponse = inferenceClient.chatComplete({\r\n messages: [{ role: MessageRole.User, content: 'Do something' }],\r\n});\r\n```\r\n\r\n*Note: this is only done for the server-side, as there isn't much value\r\nin scoping APIs on the browser side in my opinion*\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"3c8f0777f4a4563824d0fb1f545524bf4346e3a2"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200568","number":200568,"mergeCommit":{"message":"[inference] add pre-bound versions of `chatComplete` and `output` APIs (#200568)\n\n## Summary\r\n\r\nFix https://github.com/elastic/kibana/issues/199084\r\n\r\nIntroduce pre-bound versions of the inference APIs.\r\n\r\nAccessing the bound versions can be done using the same `getClient` API,\r\nvia an additional `bindTo` parameter:\r\n\r\n**without bindings**\r\n```ts\r\nconst inferenceClient = myStartDeps.inference.getClient({ request });\r\n\r\nconst chatResponse = inferenceClient.chatComplete({\r\n connectorId: 'my-connector-id',\r\n functionCalling: 'simulated',\r\n messages: [{ role: MessageRole.User, content: 'Do something' }],\r\n});\r\n```\r\n\r\n**with bindings**\r\n```ts\r\nconst inferenceClient = myStartDeps.inference.getClient({\r\n request,\r\n bindTo: {\r\n connectorId: 'my-connector-id',\r\n functionCalling: 'simulated',\r\n }\r\n});\r\n\r\nconst chatResponse = inferenceClient.chatComplete({\r\n messages: [{ role: MessageRole.User, content: 'Do something' }],\r\n});\r\n```\r\n\r\n*Note: this is only done for the server-side, as there isn't much value\r\nin scoping APIs on the browser side in my opinion*\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"3c8f0777f4a4563824d0fb1f545524bf4346e3a2"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Pierre Gayvallet <[email protected]>
elastic#200568) ## Summary Fix elastic#199084 Introduce pre-bound versions of the inference APIs. Accessing the bound versions can be done using the same `getClient` API, via an additional `bindTo` parameter: **without bindings** ```ts const inferenceClient = myStartDeps.inference.getClient({ request }); const chatResponse = inferenceClient.chatComplete({ connectorId: 'my-connector-id', functionCalling: 'simulated', messages: [{ role: MessageRole.User, content: 'Do something' }], }); ``` **with bindings** ```ts const inferenceClient = myStartDeps.inference.getClient({ request, bindTo: { connectorId: 'my-connector-id', functionCalling: 'simulated', } }); const chatResponse = inferenceClient.chatComplete({ messages: [{ role: MessageRole.User, content: 'Do something' }], }); ``` *Note: this is only done for the server-side, as there isn't much value in scoping APIs on the browser side in my opinion* --------- Co-authored-by: Elastic Machine <[email protected]>
elastic#200568) ## Summary Fix elastic#199084 Introduce pre-bound versions of the inference APIs. Accessing the bound versions can be done using the same `getClient` API, via an additional `bindTo` parameter: **without bindings** ```ts const inferenceClient = myStartDeps.inference.getClient({ request }); const chatResponse = inferenceClient.chatComplete({ connectorId: 'my-connector-id', functionCalling: 'simulated', messages: [{ role: MessageRole.User, content: 'Do something' }], }); ``` **with bindings** ```ts const inferenceClient = myStartDeps.inference.getClient({ request, bindTo: { connectorId: 'my-connector-id', functionCalling: 'simulated', } }); const chatResponse = inferenceClient.chatComplete({ messages: [{ role: MessageRole.User, content: 'Do something' }], }); ``` *Note: this is only done for the server-side, as there isn't much value in scoping APIs on the browser side in my opinion* --------- Co-authored-by: Elastic Machine <[email protected]>
elastic#200568) ## Summary Fix elastic#199084 Introduce pre-bound versions of the inference APIs. Accessing the bound versions can be done using the same `getClient` API, via an additional `bindTo` parameter: **without bindings** ```ts const inferenceClient = myStartDeps.inference.getClient({ request }); const chatResponse = inferenceClient.chatComplete({ connectorId: 'my-connector-id', functionCalling: 'simulated', messages: [{ role: MessageRole.User, content: 'Do something' }], }); ``` **with bindings** ```ts const inferenceClient = myStartDeps.inference.getClient({ request, bindTo: { connectorId: 'my-connector-id', functionCalling: 'simulated', } }); const chatResponse = inferenceClient.chatComplete({ messages: [{ role: MessageRole.User, content: 'Do something' }], }); ``` *Note: this is only done for the server-side, as there isn't much value in scoping APIs on the browser side in my opinion* --------- Co-authored-by: Elastic Machine <[email protected]>
Summary
Fix #199084
Introduce pre-bound versions of the inference APIs.
Accessing the bound versions can be done using the same
getClient
API, via an additionalbindTo
parameter:without bindings
with bindings
Note: this is only done for the server-side, as there isn't much value in scoping APIs on the browser side in my opinion