Skip to content
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

[Security Assistant] Fix abort stream OpenAI issue #203193

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

stephmilovic
Copy link
Contributor

@stephmilovic stephmilovic commented Dec 5, 2024

Summary

I made a mistake in the Abort signal fix PR. I thought I could get rid of the finish_reason condition, but we need it as some finish reasons should not end the stream.

I brought back that finish_reason === 'stop' condition and added to the condition to handleStreamEnd when there is not a finish_reason as this indicates abort.

I also found that my addition of signal to agent .invoke in order to satisfy Bedrock broke abort signal handling for OpenAI. Therefore, I added a condition to only include signal to agent .invoke when the connector is Bedrock.

To test

  1. Using OpenAI connector, ask the assistant a question you know will trigger a tool (how many open alerts do i have?). Ensure a response is streamed back
  2. Using OpenAI connector, ask the assistant a question you know will give a very long response (Write a poem about elastic security). When the response begins to stream back, hit "Stop generating". Switch conversations and return back to the original conversation. Ensure the cut-off response is persisted

@stephmilovic stephmilovic added release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) Team:Security Generative AI Security Generative AI labels Dec 5, 2024
@stephmilovic stephmilovic requested a review from a team as a code owner December 5, 2024 22:48
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

@stephmilovic stephmilovic merged commit 4b42953 into elastic:main Dec 6, 2024
17 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12197897997

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 6, 2024
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Dec 6, 2024
…203230)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Security Assistant] Fix abort stream OpenAI issue
(#203193)](#203193)

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

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

<!--BACKPORT [{"author":{"name":"Steph
Milovic","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-12-06T11:20:13Z","message":"[Security
Assistant] Fix abort stream OpenAI issue
(#203193)","sha":"4b42953aacfe903b6c9ecef4ac841348e65ed5d5","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:
SecuritySolution","backport:prev-minor","Team:Security Generative
AI"],"title":"[Security Assistant] Fix abort stream OpenAI
issue","number":203193,"url":"https://github.com/elastic/kibana/pull/203193","mergeCommit":{"message":"[Security
Assistant] Fix abort stream OpenAI issue
(#203193)","sha":"4b42953aacfe903b6c9ecef4ac841348e65ed5d5"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/203193","number":203193,"mergeCommit":{"message":"[Security
Assistant] Fix abort stream OpenAI issue
(#203193)","sha":"4b42953aacfe903b6c9ecef4ac841348e65ed5d5"}}]}]
BACKPORT-->

Co-authored-by: Steph Milovic <[email protected]>
markov00 pushed a commit to markov00/kibana that referenced this pull request Dec 7, 2024
SoniaSanzV pushed a commit to SoniaSanzV/kibana that referenced this pull request Dec 9, 2024
SoniaSanzV pushed a commit to SoniaSanzV/kibana that referenced this pull request Dec 9, 2024
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 9, 2024
Samiul-TheSoccerFan pushed a commit to Samiul-TheSoccerFan/kibana that referenced this pull request Dec 10, 2024
mykolaharmash pushed a commit to mykolaharmash/kibana that referenced this pull request Dec 11, 2024
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes Team:Security Generative AI Security Generative AI Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.18.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants