-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Obs AI Assistant] Refactor ObservabilityAIAssistantClient #181255
[Obs AI Assistant] Refactor ObservabilityAIAssistantClient #181255
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
/ci |
dbe3a89
to
a496703
Compare
/ci |
d005850
to
9a863cf
Compare
/ci |
@elasticmachine merge upstream |
/ci |
aa97a6a
to
ce4deca
Compare
/ci |
ce4deca
to
bb2d799
Compare
@elasticmachine merge upstream |
withAssistantSpan('get_connector', () => | ||
this.dependencies.actionsClient.get({ id: connectorId, throwIfSystemAction: true }) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be using guardAgainstInvalidConnector
? And should guardAgainstInvalidConnector
be calling withAssistantSpan
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, will address
predefinedTitle || isConversationUpdate || !persist | ||
? of(predefinedTitle || '').pipe(shareReplay()) | ||
: messagesWithUpdatedSystemMessage$.pipe( | ||
switchMap((messages) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every time I see switchMap
or forkJoin
I stop to think what they do.
What's the best playground for getting familiar with rxjs? Codesandbox or is there something better suited for reactive programming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like https://www.learnrxjs.io/learn-rxjs and ChatGPT!
return new Observable<ChatCompletionChunkEvent | TokenCountEvent>((subscriber) => { | ||
const shared = source$.pipe(shareReplay()); | ||
return (source$: Observable<ChatEvent>) => { | ||
const shared$ = source$.pipe(shareReplay()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: is the fact that we use shareReplay everywhere cause for concern? This holds on to every emission for the lifetime of the request so can increase memory usage quite significantly. And if we don't properly end the observable we could end up with a memory leak.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question and something we should consider. In this case that's fine I think, as the Observable is short-lived, it doesn't keep on emitting values indefinitely.
💚 Build Succeeded
Metrics [docs]Async chunks
Canvas Sharable Runtime
Public APIs missing exports
Page load bundle
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
…81255) Refactors the Observability AI Assistant server-side client. Instead of using a mix of promises and Observables, we know use Observables where possible. This leads to more readable code, and makes things like error handling and logging easier. This refactor purposely leaves the existing tests in place as much as possible. The functionality has however been broken into separate functions so we should be able to break up the existing tests into smaller pieces. --------- Co-authored-by: Kibana Machine <[email protected]> (cherry picked from commit 6eba595)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…81255) (#182237) # Backport This will backport the following commits from `main` to `8.14`: - [[Obs AI Assistant] Refactor ObservabilityAIAssistantClient (#181255)](#181255) <!--- Backport version: 7.3.2 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT {commits} BACKPORT-->
…81255) Refactors the Observability AI Assistant server-side client. Instead of using a mix of promises and Observables, we know use Observables where possible. This leads to more readable code, and makes things like error handling and logging easier. This refactor purposely leaves the existing tests in place as much as possible. The functionality has however been broken into separate functions so we should be able to break up the existing tests into smaller pieces. --------- Co-authored-by: Kibana Machine <[email protected]>
Refactors the Observability AI Assistant server-side client. Instead of using a mix of promises and Observables, we know use Observables where possible. This leads to more readable code, and makes things like error handling and logging easier.
This refactor purposely leaves the existing tests in place as much as possible. The functionality has however been broken into separate functions so we should be able to break up the existing tests into smaller pieces.