[9.0] [Bug][Assistant API] - chat/complete endpoint is not persisting the model response to the chosen conversation ID (#11783) (#212122)#212501
Merged
kibanamachine merged 1 commit intoelastic:9.0from Feb 26, 2025
Conversation
…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
💚 Build Succeeded
Metrics [docs]
cc @e40pud |
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.
Backport
This will backport the following commits from
mainto9.0:Questions ?
Please refer to the Backport tool documentation