Open spong opened 1 week ago
Pinging @elastic/security-solution (Team: SecuritySolution)
Fewer modules leads to a faster build time
id | before | after | diff |
---|---|---|---|
securitySolution |
5492 | 5497 | +5 |
Total count of every public API that lacks a comment. Target amount is 0. Run
node scripts/build_api_docs --plugin [yourplugin] --stats comments
for more detailed information.
id | before | after | diff |
---|---|---|---|
@kbn/elastic-assistant |
147 | 138 | -9 |
@kbn/elastic-assistant-common |
217 | 275 | +58 |
total | +49 |
Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app
id | before | after | diff |
---|---|---|---|
securitySolution |
15.1MB | 15.1MB | +2.5KB |
Size of the bundles that are downloaded on every page load. Target size is below 100kb
id | before | after | diff |
---|---|---|---|
securitySolution |
83.5KB | 83.5KB | +35.0B |
To update your PR or re-run it, just comment with:
@elasticmachine merge upstream
cc @spong
Summary
This PR is
Phase 1
of the Knowledge Base work for8.15
, which includes automatically setting up the Knowledge base (this PR), introducing new generic KB tools for recall/retrieval, a CRUD API for for managing Knowledge Base Entries, and a basic UI for Knowledge Base Entry management (all captured in this issue). Once complete, this will also provide the opportunity to remove the!isEnabledKnowledgeBase
code paths, directing all interactions through our LangChain Agent pipeline.This PR sets the ground work for all of the above by moving ELSER setup and Knowledge Base data management to use the new
AssistantDataClient
architecture used for Conversations, AnonymizationFields and Prompts.This feature is currently behind the
assistantKnowledgeBaseByDefault
experimental feature flag, which can be enabled by adding the following to yourkibana.dev.yml
:Once enabled, an
Install Knowledge Base
button will be shown when starting a new conversation. Note: UX is still under development.Useful Dev Tools Queries
The new
assistantKnowledgeBaseByDefault
flows are quite resilient, and so everything should function as expected even if one piece of the puzzle is missing or incomplete. Here are some dev tool queries to check and delete individual resources, which is nice for testing. For instance, you can nuke the ingest pipeline, or ELSER, and theInstall KB
button will appear and function as intended.Useful Dev Tools Queries
``` ts // New KB GET /_ingest/pipeline/.kibana-elastic-ai-assistant-ingest-pipeline-knowledge-base GET /_index_template/.kibana-elastic-ai-assistant-index-template-knowledge-base GET /_data_stream/.kibana-elastic-ai-assistant-knowledge-base-default/ GET .kibana-elastic-ai-assistant-knowledge-base-default/_count GET .kibana-elastic-ai-assistant-knowledge-base-default/_mapping GET .kibana-elastic-ai-assistant-knowledge-base-default/_search { "size": 1000 } // MSearch for if ES|QLKB docs exists GET .kibana-elastic-ai-assistant-knowledge-base-default/_msearch {} {"query":{"bool":{"must_not":[{"term":{"metadata.kbResource":"esql"}},{"term":{"metadata.required":true}}],"must":[{"text_expansion":{"vector.tokens":{"model_id":".elser_model_2","model_text":"You can chain processing commands, separated by a pipe character: `|`."}}}]}},"size":10} {} {"query":{"bool":{"must":[{"term":{"metadata.kbResource":"esql"}},{"term":{"metadata.required":true}}]}},"size":10000} // Other DataClient Assets GET .kibana-elastic-ai-assistant-anonymization-fields-default/_search { "size": 1000 } GET .kibana-elastic-ai-assistant-conversations-default/_search { "size": 1000 } GET .kibana-elastic-ai-assistant-prompts-default/_search { "size": 1000 } GET /_ingest/pipeline/.kibana-elastic-ai-assistant-ingest-pipeline-knowledge-base // Delete them all! // Data Streams DELETE /_data_stream/.kibana-elastic-ai-assistant-anonymization-fields-default DELETE /_data_stream/.kibana-elastic-ai-assistant-conversations-default DELETE /_data_stream/.kibana-elastic-ai-assistant-knowledge-base-default DELETE /_data_stream/.kibana-elastic-ai-assistant-prompts-default // Index Templates DELETE /_index_template/.kibana-elastic-ai-assistant-index-template-anonymization-fields DELETE /_index_template/.kibana-elastic-ai-assistant-index-template-conversations DELETE /_index_template/.kibana-elastic-ai-assistant-index-template-knowledge-base DELETE /_index_template/.kibana-elastic-ai-assistant-index-template-prompts // Pipelines DELETE /_ingest/pipeline/.kibana-elastic-ai-assistant-ingest-pipeline-knowledge-base ```
New Features:
assistantKnowledgeBaseByDefault
experimental feature flag and exposed throughassistantCapabilities
APIassistantFeatures
made available in AssistantProvider and tests (no need to individually plumb new features)AIAssistantDataClient
for creating Data Streams, Component Templates, and Ingest PipelineAIAssistantDataClient
to automatically install ELSER viainstallElasticModel()
API, then deploy via TrainedModelsAPIaddKnowledgeBaseDocuments()
for creating KB entries from LangChainDocuments
withinAIAssistantDataClient
ElasticsearchStore
to take akbDataClient
for use in document adding/retrievalChanges not behind FF:
getELSER()
helper function to be called byinternalUser
to prevent ml privilege requirements to setup Knowledge Base once a privileged user has enabled ELSERget/post/delete
knowledge base routes to createesStore
asinternalUser
to enable all assistant users the ability to enable the KB once ELSER has been installed (currently they503
if currentUser doesn't haveread_ingest
andmanage
/read
for the.kibana-elastic-ai-assistant-kb index
)get/post/delete
knowledge base routes with assistant API access controls:tags: ['access:elasticAssistant'],
Checklist
Delete any items that are not applicable to this PR.