-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Obs AI Assistant] Add query rewriting #224498
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
Conversation
x-pack/platform/plugins/shared/observability_ai_assistant/server/functions/context.ts
Outdated
Show resolved
Hide resolved
|
Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
54036a7 to
207a1bc
Compare
| ? [`--xpack.fleet.registryUrl=http://localhost:${dockerRegistryPort}`] | ||
| : []), | ||
| // @ts-expect-error | ||
| ...(options?.kbnTestServer?.serverArgs ?? []), |
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.
Why are you doing this given the error we throw on line 44 if options.kbnServerArgs is set?
I think you can customize the kbnServer args in specific configs but not in this shared one if I remember correctly.
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.
Hey!
I want to enable debug logging in Kibana for the Obs AI Assistant plugin when running the Obs AI Assistant tests:
https://github.com/sorenlouv/kibana/blob/add-query-rewriting/x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.ai_assistant.stateful.config.ts
What's the right way to do this?
Why are you doing this given the error we throw on line 44 if options.kbnServerArgs is set?
btw yes, we throw an error for options.kbnServerArgs but not for options.kbnTestServer afaict.
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'm not sure, maybe someone from @elastic/appex-qa has more context on why we don't allow sending options.kbnServerArgs and if this usage of adding options?.kbnTestServer?.serverArgs is fine.
maybe @dmlemeshko
viduni94
left a comment
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.
Added a few comments.
I tested recalling and scoring in a normal conversation, contextual insights and via the evaluation framework scenario.
LGTM
...rm/plugins/shared/observability_ai_assistant/server/functions/context/utils/query_rewrite.ts
Outdated
Show resolved
Hide resolved
...rm/plugins/shared/observability_ai_assistant/server/functions/context/utils/query_rewrite.ts
Outdated
Show resolved
Hide resolved
...ation/deployment_agnostic/apis/observability/ai_assistant/complete/functions/context.spec.ts
Outdated
Show resolved
Hide resolved
...ation/deployment_agnostic/apis/observability/ai_assistant/complete/functions/context.spec.ts
Outdated
Show resolved
Hide resolved
...ation/deployment_agnostic/apis/observability/ai_assistant/complete/functions/context.spec.ts
Outdated
Show resolved
Hide resolved
...ation/deployment_agnostic/apis/observability/ai_assistant/complete/functions/context.spec.ts
Outdated
Show resolved
Hide resolved
x-pack/test/observability_ai_assistant_api_integration/common/create_llm_proxy.ts
Show resolved
Hide resolved
x-pack/test/observability_ai_assistant_api_integration/common/create_llm_proxy.ts
Outdated
Show resolved
Hide resolved
x-pack/test/observability_ai_assistant_api_integration/common/create_llm_proxy.ts
Outdated
Show resolved
Hide resolved
...rm/plugins/shared/observability_ai_assistant/server/functions/context/utils/query_rewrite.ts
Outdated
Show resolved
Hide resolved
dmlemeshko
left a comment
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.
extended logger change LGTM
Co-authored-by: Viduni Wickramarachchi <[email protected]>
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
|
|
Starting backport for target branches: 8.19 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
Closes elastic#224084 This improves the knowledge base retrieval by rewriting the user prompt before querying Elasticsearch. The LLM is asked to rewrite the prompt taking into account screen description and conversation history. We then use the LLM-generated prompt as the search query. Other changes: - Remove `screenContext` from being used verbatim as ES query. This was causing noise and leading to bad results - Take conversation history into account: with query rewriting, the LLM has access to the entire conversation history. This context will be embedded into the generated prompt along side screen context --------- Co-authored-by: Viduni Wickramarachchi <[email protected]>
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Closes elastic#224084 This improves the knowledge base retrieval by rewriting the user prompt before querying Elasticsearch. The LLM is asked to rewrite the prompt taking into account screen description and conversation history. We then use the LLM-generated prompt as the search query. Other changes: - Remove `screenContext` from being used verbatim as ES query. This was causing noise and leading to bad results - Take conversation history into account: with query rewriting, the LLM has access to the entire conversation history. This context will be embedded into the generated prompt along side screen context --------- Co-authored-by: Viduni Wickramarachchi <[email protected]> (cherry picked from commit da41b47) # Conflicts: # x-pack/solutions/observability/plugins/observability_ai_assistant_app/scripts/evaluation/scenarios/kb/index.spec.ts # x-pack/test/api_integration/deployment_agnostic/apis/observability/ai_assistant/complete/functions/execute_query.spec.ts # x-pack/test/api_integration/deployment_agnostic/apis/observability/ai_assistant/complete/functions/get_alerts_dataset_info.spec.ts # x-pack/test/api_integration/deployment_agnostic/apis/observability/ai_assistant/complete/functions/get_dataset_info.spec.ts # x-pack/test/api_integration/deployment_agnostic/apis/observability/ai_assistant/complete/functions/retrieve_elastic_doc.spec.ts # x-pack/test/api_integration/deployment_agnostic/configs/stateful/oblt.ai_assistant.stateful.config.ts
# Backport This will backport the following commits from `main` to `8.19`: - [[Obs AI Assistant] Add query rewriting (#224498)](#224498) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Søren Louv-Jansen","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-06-24T16:19:15Z","message":"[Obs AI Assistant] Add query rewriting (#224498)\n\nCloses https://github.com/elastic/kibana/issues/224084\n\nThis improves the knowledge base retrieval by rewriting the user prompt\nbefore querying Elasticsearch. The LLM is asked to rewrite the prompt\ntaking into account screen description and conversation history. We then\nuse the LLM-generated prompt as the search query.\n\nOther changes:\n\n- Remove `screenContext` from being used verbatim as ES query. This was\ncausing noise and leading to bad results\n- Take conversation history into account: with query rewriting, the LLM\nhas access to the entire conversation history. This context will be\nembedded into the generated prompt along side screen context\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>","sha":"da41b47f1d2b297449377722ea0804880f0588ff","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","backport missing","Team:Obs AI Assistant","ci:project-deploy-observability","backport:version","v9.1.0","v8.19.0"],"title":"[Obs AI Assistant] Add query rewriting","number":224498,"url":"https://github.com/elastic/kibana/pull/224498","mergeCommit":{"message":"[Obs AI Assistant] Add query rewriting (#224498)\n\nCloses https://github.com/elastic/kibana/issues/224084\n\nThis improves the knowledge base retrieval by rewriting the user prompt\nbefore querying Elasticsearch. The LLM is asked to rewrite the prompt\ntaking into account screen description and conversation history. We then\nuse the LLM-generated prompt as the search query.\n\nOther changes:\n\n- Remove `screenContext` from being used verbatim as ES query. This was\ncausing noise and leading to bad results\n- Take conversation history into account: with query rewriting, the LLM\nhas access to the entire conversation history. This context will be\nembedded into the generated prompt along side screen context\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>","sha":"da41b47f1d2b297449377722ea0804880f0588ff"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/224498","number":224498,"mergeCommit":{"message":"[Obs AI Assistant] Add query rewriting (#224498)\n\nCloses https://github.com/elastic/kibana/issues/224084\n\nThis improves the knowledge base retrieval by rewriting the user prompt\nbefore querying Elasticsearch. The LLM is asked to rewrite the prompt\ntaking into account screen description and conversation history. We then\nuse the LLM-generated prompt as the search query.\n\nOther changes:\n\n- Remove `screenContext` from being used verbatim as ES query. This was\ncausing noise and leading to bad results\n- Take conversation history into account: with query rewriting, the LLM\nhas access to the entire conversation history. This context will be\nembedded into the generated prompt along side screen context\n\n---------\n\nCo-authored-by: Viduni Wickramarachchi <[email protected]>","sha":"da41b47f1d2b297449377722ea0804880f0588ff"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Søren Louv-Jansen <[email protected]>
Closes #224084
This improves the knowledge base retrieval by rewriting the user prompt before querying Elasticsearch. The LLM is asked to rewrite the prompt taking into account screen description and conversation history. We then use the LLM-generated prompt as the search query.
Other changes:
screenContextfrom being used verbatim as ES query. This was causing noise and leading to bad results