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

[Obs AI Assistant] Perform functions and LLM interactions on the server #172590

Merged

Conversation

dgieselaar
Copy link
Member

@dgieselaar dgieselaar commented Dec 5, 2023

Adds a /complete endpoint that handles function execution and LLM interactions on the server. This removes the need for a browser to have a conversation with the Assistant, which makes it easier to test and allows the user to script interactions. This is part of our GA effort for 8.12.

There are two open items:

  • importing the schema validator on the server breaks due to ERR_REQUIRE_ESM. Will need to find a solution or find a replacement.
  • I've removed the Kibana function because it's no longer reasonable to use http to call any Kibana API. Will look into alternatives. I have reinstated the Kibana function with a disgusting workaround 🌚

@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@dgieselaar dgieselaar marked this pull request as ready for review December 5, 2023 15:41
@dgieselaar dgieselaar requested review from a team as code owners December 5, 2023 15:41
@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label Dec 5, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:APM)

Copy link
Contributor

@gsoldevila gsoldevila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Core changes LGTM (code review only)

@neptunian
Copy link
Contributor

Verified the apm functions work as expected

Comment on lines +73 to +81
return axios({
method,
headers: request.headers,
url: format(nextUrl),
data: body ? JSON.stringify(body) : undefined,
signal,
}).then((response) => {
return { content: response.data };
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ab8c229496701a3c93896c03d0a251dc00d0428b5e74c8f1da2d40985648dca6

// eslint-disable-next-line @kbn/i18n/strings_should_be_translated_with_i18n
<div>Hello! {name}</div>
renderFunction: (name) => (
<div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<div>
// eslint-disable-next-line @kbn/i18n/strings_should_be_translated_with_i18n
<div>Hello! {name}</div>

Copy link
Contributor

@CoenWarmer CoenWarmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good!

Copy link
Contributor

@miltonhultgren miltonhultgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked at the code in server only, so far it looks good.
Left a mix of nits and questions mostly

export function processOpenAiStream() {
return (source: Observable<string>): Observable<CreateChatCompletionResponseChunk> =>
source.pipe(
map((line) => line.substring(6)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the first 6 characters that we drop?

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
apm 1546 1539 -7
observabilityAIAssistant 226 212 -14
total -21

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 3.7MB 3.7MB -16.2KB
observabilityAIAssistant 204.4KB 146.5KB -57.9KB
total -74.1KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
apm 127 125 -2
observabilityAIAssistant 9 12 +3
total +1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
apm 36.8KB 36.7KB -69.0B
observabilityAIAssistant 15.8KB 15.6KB -225.0B
total -294.0B
Unknown metric groups

async chunk count

id before after diff
observabilityAIAssistant 7 6 -1

ESLint disabled in files

id before after diff
observabilityAIAssistant 3 4 +1

ESLint disabled line counts

id before after diff
observabilityAIAssistant 4 3 -1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@dgieselaar dgieselaar merged commit 56b36b9 into elastic:main Dec 7, 2023
40 checks passed
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 7, 2023
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit 56b36b9)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.12

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 7, 2023
… (#172824)

# Backport

This will backport the following commits from `main` to `8.12`:
- [[Obs AI Assistant] Perform functions etc on the server
(#172590)](#172590)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Dario
Gieselaar","email":"dario.gieselaar@elastic.co"},"sourceCommit":{"committedDate":"2023-12-07T14:18:41Z","message":"[Obs
AI Assistant] Perform functions etc on the server
(#172590)\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"56b36b9042b42c702a57568f1612af3d433d2df1","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Team:APM","v8.12.0","apm:review","v8.13.0"],"number":172590,"url":"#172590
AI Assistant] Perform functions etc on the server
(#172590)\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"56b36b9042b42c702a57568f1612af3d433d2df1"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"#172590
AI Assistant] Perform functions etc on the server
(#172590)\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"56b36b9042b42c702a57568f1612af3d433d2df1"}}]}]
BACKPORT-->

Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet