[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783)#212122
Merged
e40pud merged 3 commits intoelastic:mainfrom Feb 26, 2025
Conversation
…odel response to the chosen conversation ID (elastic#11783)
Contributor
|
Pinging @elastic/security-solution (Team: SecuritySolution) |
YulNaumenko
approved these changes
Feb 25, 2025
Contributor
YulNaumenko
left a comment
There was a problem hiding this comment.
LGTM! Tested locally, works as expected.
Thank you for the fix @e40pud
# Conflicts: # x-pack/solutions/security/plugins/elastic_assistant/server/routes/chat/chat_complete_route.ts
Contributor
💚 Build Succeeded
Metrics [docs]
History
cc @e40pud |
Contributor
|
Starting backport for target branches: 8.17, 8.18, 8.x, 9.0 https://github.com/elastic/kibana/actions/runs/13542392339 |
kibanamachine
pushed a commit
to kibanamachine/kibana
that referenced
this pull request
Feb 26, 2025
…odel response to the chosen conversation ID (elastic#11783) (elastic#212122) ## Summary BUG: elastic/security-team#11783 This PR fixes the behaviour of the `/api/security_ai_assistant/chat/complete` route where the `persist` flag: 1. when set to `true` does not append the assistant reply to existing conversation 2. when set to `false` appends user message to existing conversation ### Expected behaviour [Details](elastic/security-team#11783 (comment)). 1. `conversationId == undefined && persist == false`: no new conversations and nothing persisted 2. `conversationId == undefined && persist == true`: new conversations is created and both user message and assistant reply appended to the new conversation 3. `conversationId == 'existing-id' && persist == false`: nothing appended to the existing conversation 4. `conversationId == 'existing-id' && persist == true`: both user message and assistant reply appended to the existing conversation ### Testing * Use this `curl` command (with replace `connectorId` and `conversationId`) to test the endpoint. ``` curl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \ --header 'kbn-xsrf: true' \ --header 'Content-Type: application/json' \ --data '{ "connectorId": "{{my-gpt4o-ai}}", "conversationId": "{{existing-conversation-id | undefined}}", "isStream": false, "messages": [ { "content": "Follow up", "role": "user" } ], "persist": true }' ``` * To retrieve the conversation ID: (/api/security_ai_assistant/current_user/conversations/_find) * `conversationId` can be either existing conversation id or `undefined` (cherry picked from commit a2b2e81)
kibanamachine
pushed a commit
to kibanamachine/kibana
that referenced
this pull request
Feb 26, 2025
…odel response to the chosen conversation ID (elastic#11783) (elastic#212122) ## Summary BUG: elastic/security-team#11783 This PR fixes the behaviour of the `/api/security_ai_assistant/chat/complete` route where the `persist` flag: 1. when set to `true` does not append the assistant reply to existing conversation 2. when set to `false` appends user message to existing conversation ### Expected behaviour [Details](elastic/security-team#11783 (comment)). 1. `conversationId == undefined && persist == false`: no new conversations and nothing persisted 2. `conversationId == undefined && persist == true`: new conversations is created and both user message and assistant reply appended to the new conversation 3. `conversationId == 'existing-id' && persist == false`: nothing appended to the existing conversation 4. `conversationId == 'existing-id' && persist == true`: both user message and assistant reply appended to the existing conversation ### Testing * Use this `curl` command (with replace `connectorId` and `conversationId`) to test the endpoint. ``` curl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \ --header 'kbn-xsrf: true' \ --header 'Content-Type: application/json' \ --data '{ "connectorId": "{{my-gpt4o-ai}}", "conversationId": "{{existing-conversation-id | undefined}}", "isStream": false, "messages": [ { "content": "Follow up", "role": "user" } ], "persist": true }' ``` * To retrieve the conversation ID: (/api/security_ai_assistant/current_user/conversations/_find) * `conversationId` can be either existing conversation id or `undefined` (cherry picked from commit a2b2e81)
Contributor
💔 Some backports could not be created
Note: Successful backport PRs will be merged automatically after passing CI. Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
e40pud
added a commit
to e40pud/kibana
that referenced
this pull request
Feb 26, 2025
…odel response to the chosen conversation ID (elastic#11783) (elastic#212122) ## Summary BUG: elastic/security-team#11783 This PR fixes the behaviour of the `/api/security_ai_assistant/chat/complete` route where the `persist` flag: 1. when set to `true` does not append the assistant reply to existing conversation 2. when set to `false` appends user message to existing conversation ### Expected behaviour [Details](elastic/security-team#11783 (comment)). 1. `conversationId == undefined && persist == false`: no new conversations and nothing persisted 2. `conversationId == undefined && persist == true`: new conversations is created and both user message and assistant reply appended to the new conversation 3. `conversationId == 'existing-id' && persist == false`: nothing appended to the existing conversation 4. `conversationId == 'existing-id' && persist == true`: both user message and assistant reply appended to the existing conversation ### Testing * Use this `curl` command (with replace `connectorId` and `conversationId`) to test the endpoint. ``` curl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \ --header 'kbn-xsrf: true' \ --header 'Content-Type: application/json' \ --data '{ "connectorId": "{{my-gpt4o-ai}}", "conversationId": "{{existing-conversation-id | undefined}}", "isStream": false, "messages": [ { "content": "Follow up", "role": "user" } ], "persist": true }' ``` * To retrieve the conversation ID: (/api/security_ai_assistant/current_user/conversations/_find) * `conversationId` can be either existing conversation id or `undefined` (cherry picked from commit a2b2e81) # Conflicts: # x-pack/solutions/security/plugins/elastic_assistant/server/routes/chat/chat_complete_route.ts
Contributor
Author
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
e40pud
added a commit
to e40pud/kibana
that referenced
this pull request
Feb 26, 2025
…odel response to the chosen conversation ID (elastic#11783) (elastic#212122) ## Summary BUG: elastic/security-team#11783 This PR fixes the behaviour of the `/api/security_ai_assistant/chat/complete` route where the `persist` flag: 1. when set to `true` does not append the assistant reply to existing conversation 2. when set to `false` appends user message to existing conversation ### Expected behaviour [Details](elastic/security-team#11783 (comment)). 1. `conversationId == undefined && persist == false`: no new conversations and nothing persisted 2. `conversationId == undefined && persist == true`: new conversations is created and both user message and assistant reply appended to the new conversation 3. `conversationId == 'existing-id' && persist == false`: nothing appended to the existing conversation 4. `conversationId == 'existing-id' && persist == true`: both user message and assistant reply appended to the existing conversation ### Testing * Use this `curl` command (with replace `connectorId` and `conversationId`) to test the endpoint. ``` curl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \ --header 'kbn-xsrf: true' \ --header 'Content-Type: application/json' \ --data '{ "connectorId": "{{my-gpt4o-ai}}", "conversationId": "{{existing-conversation-id | undefined}}", "isStream": false, "messages": [ { "content": "Follow up", "role": "user" } ], "persist": true }' ``` * To retrieve the conversation ID: (/api/security_ai_assistant/current_user/conversations/_find) * `conversationId` can be either existing conversation id or `undefined` (cherry picked from commit a2b2e81) # Conflicts: # x-pack/plugins/elastic_assistant/server/routes/chat/chat_complete_route.ts
kibanamachine
added a commit
that referenced
this pull request
Feb 26, 2025
… the model response to the chosen conversation ID (#11783) (#212122) (#212501) # Backport This will backport the following commits from `main` to `9.0`: - [[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)](#212122) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ievgen Sorokopud","email":"ievgen.sorokopud@elastic.co"},"sourceCommit":{"committedDate":"2025-02-26T11:03:09Z","message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23","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: SecuritySolution","Team:Security Generative AI","backport:version","v8.17.0","v8.18.0","v9.1.0","v8.19.0"],"title":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783)","number":212122,"url":"https://github.com/elastic/kibana/pull/212122","mergeCommit":{"message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.17","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.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/212122","number":212122,"mergeCommit":{"message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Ievgen Sorokopud <ievgen.sorokopud@elastic.co>
kibanamachine
added a commit
that referenced
this pull request
Feb 26, 2025
…g the model response to the chosen conversation ID (#11783) (#212122) (#212500) # Backport This will backport the following commits from `main` to `8.18`: - [[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)](#212122) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ievgen Sorokopud","email":"ievgen.sorokopud@elastic.co"},"sourceCommit":{"committedDate":"2025-02-26T11:03:09Z","message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23","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: SecuritySolution","Team:Security Generative AI","backport:version","v8.17.0","v8.18.0","v9.1.0","v8.19.0"],"title":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783)","number":212122,"url":"https://github.com/elastic/kibana/pull/212122","mergeCommit":{"message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.17","8.18","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.17","label":"v8.17.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/212122","number":212122,"mergeCommit":{"message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Ievgen Sorokopud <ievgen.sorokopud@elastic.co>
e40pud
added a commit
that referenced
this pull request
Feb 26, 2025
…g the model response to the chosen conversation ID (#11783) (#212122) (#212505) # Backport This will backport the following commits from `main` to `8.17`: - [[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)](#212122) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ievgen Sorokopud","email":"ievgen.sorokopud@elastic.co"},"sourceCommit":{"committedDate":"2025-02-26T11:03:09Z","message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23","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: SecuritySolution","Team:Security Generative AI","backport:version","v8.17.0","v8.18.0","v9.1.0","v8.19.0"],"title":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783)","number":212122,"url":"https://github.com/elastic/kibana/pull/212122","mergeCommit":{"message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/212501","number":212501,"state":"OPEN"},{"branch":"8.17","label":"v8.17.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,"url":"https://github.com/elastic/kibana/pull/212500","number":212500,"state":"OPEN"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212122","number":212122,"mergeCommit":{"message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
e40pud
added a commit
that referenced
this pull request
Feb 26, 2025
… the model response to the chosen conversation ID (#11783) (#212122) (#212504) # Backport This will backport the following commits from `main` to `8.x`: - [[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)](#212122) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ievgen Sorokopud","email":"ievgen.sorokopud@elastic.co"},"sourceCommit":{"committedDate":"2025-02-26T11:03:09Z","message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23","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: SecuritySolution","Team:Security Generative AI","backport:version","v8.17.0","v8.18.0","v9.1.0","v8.19.0"],"title":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783)","number":212122,"url":"https://github.com/elastic/kibana/pull/212122","mergeCommit":{"message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/212501","number":212501,"state":"OPEN"},{"branch":"8.17","label":"v8.17.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,"url":"https://github.com/elastic/kibana/pull/212500","number":212500,"state":"OPEN"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212122","number":212122,"mergeCommit":{"message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
JoseLuisGJ
pushed a commit
to JoseLuisGJ/kibana
that referenced
this pull request
Feb 27, 2025
…odel response to the chosen conversation ID (elastic#11783) (elastic#212122) ## Summary BUG: elastic/security-team#11783 This PR fixes the behaviour of the `/api/security_ai_assistant/chat/complete` route where the `persist` flag: 1. when set to `true` does not append the assistant reply to existing conversation 2. when set to `false` appends user message to existing conversation ### Expected behaviour [Details](elastic/security-team#11783 (comment)). 1. `conversationId == undefined && persist == false`: no new conversations and nothing persisted 2. `conversationId == undefined && persist == true`: new conversations is created and both user message and assistant reply appended to the new conversation 3. `conversationId == 'existing-id' && persist == false`: nothing appended to the existing conversation 4. `conversationId == 'existing-id' && persist == true`: both user message and assistant reply appended to the existing conversation ### Testing * Use this `curl` command (with replace `connectorId` and `conversationId`) to test the endpoint. ``` curl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \ --header 'kbn-xsrf: true' \ --header 'Content-Type: application/json' \ --data '{ "connectorId": "{{my-gpt4o-ai}}", "conversationId": "{{existing-conversation-id | undefined}}", "isStream": false, "messages": [ { "content": "Follow up", "role": "user" } ], "persist": true }' ``` * To retrieve the conversation ID: (/api/security_ai_assistant/current_user/conversations/_find) * `conversationId` can be either existing conversation id or `undefined`
SoniaSanzV
pushed a commit
to SoniaSanzV/kibana
that referenced
this pull request
Mar 4, 2025
… the model response to the chosen conversation ID (elastic#11783) (elastic#212122) (elastic#212504) # Backport This will backport the following commits from `main` to `8.x`: - [[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (elastic#11783) (elastic#212122)](elastic#212122) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ievgen Sorokopud","email":"ievgen.sorokopud@elastic.co"},"sourceCommit":{"committedDate":"2025-02-26T11:03:09Z","message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (elastic#11783) (elastic#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23","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: SecuritySolution","Team:Security Generative AI","backport:version","v8.17.0","v8.18.0","v9.1.0","v8.19.0"],"title":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (elastic#11783)","number":212122,"url":"https://github.com/elastic/kibana/pull/212122","mergeCommit":{"message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (elastic#11783) (elastic#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23"}},"sourceBranch":"main","suggestedTargetBranches":["8.17","8.x"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/212501","number":212501,"state":"OPEN"},{"branch":"8.17","label":"v8.17.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,"url":"https://github.com/elastic/kibana/pull/212500","number":212500,"state":"OPEN"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/212122","number":212122,"mergeCommit":{"message":"[Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (elastic#11783) (elastic#212122)\n\n## Summary\n\nBUG: https://github.com/elastic/security-team/issues/11783\n\nThis PR fixes the behaviour of the\n`/api/security_ai_assistant/chat/complete` route where the `persist`\nflag:\n1. when set to `true` does not append the assistant reply to existing\nconversation\n2. when set to `false` appends user message to existing conversation\n\n### Expected behaviour\n\n\n[Details](https://github.com/elastic/security-team/issues/11783#issuecomment-2674565194).\n\n1. `conversationId == undefined && persist == false`: no new\nconversations and nothing persisted\n2. `conversationId == undefined && persist == true`: new conversations\nis created and both user message and assistant reply appended to the new\nconversation\n3. `conversationId == 'existing-id' && persist == false`: nothing\nappended to the existing conversation\n4. `conversationId == 'existing-id' && persist == true`: both user\nmessage and assistant reply appended to the existing conversation\n\n### Testing\n\n* Use this `curl` command (with replace `connectorId` and\n`conversationId`) to test the endpoint.\n\n```\ncurl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \\\n--header 'kbn-xsrf: true' \\\n--header 'Content-Type: application/json' \\\n--data '{\n \"connectorId\": \"{{my-gpt4o-ai}}\",\n \"conversationId\": \"{{existing-conversation-id | undefined}}\",\n \"isStream\": false,\n \"messages\": [\n {\n \"content\": \"Follow up\",\n \"role\": \"user\"\n }\n ],\n \"persist\": true\n}'\n```\n\n* To retrieve the conversation ID:\n(/api/security_ai_assistant/current_user/conversations/_find)\n* `conversationId` can be either existing conversation id or `undefined`","sha":"a2b2e81b5b74ffc56302953d186a36984b3b1c23"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
CAWilson94
pushed a commit
to CAWilson94/kibana
that referenced
this pull request
Mar 22, 2025
…odel response to the chosen conversation ID (elastic#11783) (elastic#212122) ## Summary BUG: elastic/security-team#11783 This PR fixes the behaviour of the `/api/security_ai_assistant/chat/complete` route where the `persist` flag: 1. when set to `true` does not append the assistant reply to existing conversation 2. when set to `false` appends user message to existing conversation ### Expected behaviour [Details](elastic/security-team#11783 (comment)). 1. `conversationId == undefined && persist == false`: no new conversations and nothing persisted 2. `conversationId == undefined && persist == true`: new conversations is created and both user message and assistant reply appended to the new conversation 3. `conversationId == 'existing-id' && persist == false`: nothing appended to the existing conversation 4. `conversationId == 'existing-id' && persist == true`: both user message and assistant reply appended to the existing conversation ### Testing * Use this `curl` command (with replace `connectorId` and `conversationId`) to test the endpoint. ``` curl --location 'http://localhost:5601/api/security_ai_assistant/chat/complete' \ --header 'kbn-xsrf: true' \ --header 'Content-Type: application/json' \ --data '{ "connectorId": "{{my-gpt4o-ai}}", "conversationId": "{{existing-conversation-id | undefined}}", "isStream": false, "messages": [ { "content": "Follow up", "role": "user" } ], "persist": true }' ``` * To retrieve the conversation ID: (/api/security_ai_assistant/current_user/conversations/_find) * `conversationId` can be either existing conversation id or `undefined`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BUG: https://github.com/elastic/security-team/issues/11783
This PR fixes the behaviour of the
/api/security_ai_assistant/chat/completeroute where thepersistflag:truedoes not append the assistant reply to existing conversationfalseappends user message to existing conversationExpected behaviour
Details.
conversationId == undefined && persist == false: no new conversations and nothing persistedconversationId == undefined && persist == true: new conversations is created and both user message and assistant reply appended to the new conversationconversationId == 'existing-id' && persist == false: nothing appended to the existing conversationconversationId == 'existing-id' && persist == true: both user message and assistant reply appended to the existing conversationTesting
curlcommand (with replaceconnectorIdandconversationId) to test the endpoint.conversationIdcan be either existing conversation id orundefined