kibana/.github
Pierre Gayvallet 1c218f9846
Introduce the InferenceChatModel for langchain (#206429)
## Summary

Part of https://github.com/elastic/kibana/issues/206710

This PR introduces the `InferenceChatModel` class, which is a langchain
chatModel utilizing the inference APIs (`chatComplete`) under the hood.

Creating instances of `InferenceChatModel` can either be done by
manually importing the class from the new `@kbn/inference-langchain`
package, or by using the new `createChatModel` API exposes from the
inference plugin's start contract.

The main upside of using this chatModel is that the unification and
normalization layers are already being taken care of by the inference
plugin, making sure that the underlying models are being used with the
exact same capabilities. More details on the upsides and reasoning in
the associated issue.

### Usage

Usage is very straightforward

```ts
const chatModel = await inferenceStart.getChatModel({
  request,
  connectorId: myInferenceConnectorId,
  chatModelOptions: {
    temperature: 0.2,
  },
});

// just use it as another langchain chatModel, e.g.
const response = await chatModel.stream('What is Kibana?');
for await (const chunk of response) {
     // do something with the chunk
}
``` 

### Important

This PR is only adding the implementation, and not wiring it anywhere or
using it in any existing code. This is meant to be done in a later
stage. Merging that implementation first will allow to have distinct PRs
for the integration with search (playground) and security (assistant +
other workflows), with proper testing

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2025-02-03 11:32:16 +01:00
..
codeql SKA: Relocate core mock and test-helper modules (#208538) 2025-01-29 12:14:44 +01:00
ISSUE_TEMPLATE Remove 8.0 breaking change template (#157044) 2023-05-08 15:25:24 -04:00
updatecli/values.d ci(bump automation): bump ubi9 for ironbank (#191660) 2024-10-10 22:00:38 +02:00
workflows github-action: Add AsciiDoc freeze warning (#208534) 2025-01-30 16:41:18 +00:00
CODEOWNERS Introduce the InferenceChatModel for langchain (#206429) 2025-02-03 11:32:16 +01:00
ISSUE_TEMPLATE.md Add elasticsearch version to issue template 2016-07-25 11:00:27 -05:00
paths-labeller.yml SKA: Follow-up relocation (#207041) 2025-01-27 20:02:57 +01:00
PULL_REQUEST_TEMPLATE.md Sustainable Kibana Architecture: Move modules owned by @elastic/kibana-core (#201653) 2025-01-04 11:47:24 -07:00
relabel.yml Improve needs-team auto labeling regex (#143787) 2022-10-27 09:03:34 -07:00
stale.yml Remove Infra Monitoring UI team (#175745) 2024-01-30 13:33:57 -06:00