Skip to content

Commit

Permalink
[9.0] Pass system message to inferenceCliente.chatComplete (elastic#2…
Browse files Browse the repository at this point in the history
…11263) (elastic#211360)

# Backport

This will backport the following commits from `main` to `9.0`:
- [Pass system message to inferenceCliente.chatComplete
(elastic#211263)](elastic#211263)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Arturo
Lidueña","email":"arturo.liduena@elastic.co"},"sourceCommit":{"committedDate":"2025-02-16T08:43:50Z","message":"Pass
system message to inferenceCliente.chatComplete (elastic#211263)\n\nCloses
elastic#211257 \r\n\r\n## Summary\r\n\r\nRegression introduced in
8.18\r\n(https://github.com/elastic/kibana/pull/199286)\r\n\r\nWe no
longer pass the `system` message to the inference plugin, and\r\nthereby
the LLM. This means that we are only passing user messages to\r\nthe
LLM. The system message is important in steering the
conversation,\r\nand providing guardrails to the
LLM.","sha":"117802cbb2ba73df14f82a2ee1caee1bfe5b1ced","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","v9.0.0","Team:Obs
AI
Assistant","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"Pass
system message to
inferenceCliente.chatComplete","number":211263,"url":"https://github.com/elastic/kibana/pull/211263","mergeCommit":{"message":"Pass
system message to inferenceCliente.chatComplete (elastic#211263)\n\nCloses
elastic#211257 \r\n\r\n## Summary\r\n\r\nRegression introduced in
8.18\r\n(https://github.com/elastic/kibana/pull/199286)\r\n\r\nWe no
longer pass the `system` message to the inference plugin, and\r\nthereby
the LLM. This means that we are only passing user messages to\r\nthe
LLM. The system message is important in steering the
conversation,\r\nand providing guardrails to the
LLM.","sha":"117802cbb2ba73df14f82a2ee1caee1bfe5b1ced"}},"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/211263","number":211263,"mergeCommit":{"message":"Pass
system message to inferenceCliente.chatComplete (elastic#211263)\n\nCloses
elastic#211257 \r\n\r\n## Summary\r\n\r\nRegression introduced in
8.18\r\n(https://github.com/elastic/kibana/pull/199286)\r\n\r\nWe no
longer pass the `system` message to the inference plugin, and\r\nthereby
the LLM. This means that we are only passing user messages to\r\nthe
LLM. The system message is important in steering the
conversation,\r\nand providing guardrails to the
LLM.","sha":"117802cbb2ba73df14f82a2ee1caee1bfe5b1ced"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Arturo Lidueña <arturo.liduena@elastic.co>
  • Loading branch information
kibanamachine and arturoliduena authored Feb 16, 2025
1 parent e60774c commit 4aaf263
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ describe('Observability AI Assistant client', () => {
{
connectorId: 'foo',
stream: true,
system: EXPECTED_STORED_SYSTEM_MESSAGE,
messages: expect.arrayContaining([
{ role: 'user', content: 'How many alerts do I have?' },
]),
Expand Down Expand Up @@ -916,6 +917,7 @@ describe('Observability AI Assistant client', () => {
{
connectorId: 'foo',
stream: true,
system: EXPECTED_STORED_SYSTEM_MESSAGE,
messages: expect.arrayContaining([
{ role: 'user', content: 'How many alerts do I have?' },
]),
Expand Down Expand Up @@ -1077,6 +1079,7 @@ describe('Observability AI Assistant client', () => {
{
connectorId: 'foo',
stream: true,
system: EXPECTED_STORED_SYSTEM_MESSAGE,
messages: expect.arrayContaining([
{ role: 'user', content: 'How many alerts do I have?' },
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ export class ObservabilityAIAssistantClient {

const options = {
connectorId,
system: messages.find((message) => message.message.role === MessageRole.System)?.message
.content,
messages: convertMessagesForInference(
messages.filter((message) => message.message.role !== MessageRole.System)
),
Expand Down

0 comments on commit 4aaf263

Please sign in to comment.