[8.19] [Obs AI Assistant] Add custom plugin for highlighting user and assistant responses when they have redacted entities (#224605)#225305
Merged
SrdjanLL merged 1 commit intoelastic:8.19from Jun 25, 2025
Conversation
…ant responses when they have redacted entities (elastic#224605) Closes: elastic/obs-ai-team#264 ## Summary Add custom plugin for highlighting user and assistant responses when they have redacted entities: - Custom plugin for `EuiMarkdownFormat` that highlights all content wrapped inside anonymized node. The parsing plugin follows the approach from [EUI docs](https://eui.elastic.co/docs/components/editors-and-syntax/markdown/plugins/#putting-it-all-together-a-simple-chart-plugin) and is used as follows: ``` !{anonymized{"entityClass":"<entity class>", "content": "<content"}} ``` - Highlighted content is currently rendered as `EuiCode`, but it can be more sophisticated (i.e highlight differently depending on the entity class). - Allows using the same highlighting logic for messages from both `user` and `assistant` roles. - Currently **skipping highlighting inside the code blocks** - may require customising the default plugins further. Manually tested: - Function calling seems to work as expected. - Search results with PII are highlighted in the table. - Custom regex matches are highlighted correctly. ### Testing instructions: 1. Used setup from elastic#216352 to set up NER model locally. 2. Added to `kibana.dev.yml`: ``` uiSettings: overrides: 'observability:aiAssistantAnonymizationRules': | [ { "type": "regex", "pattern": "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[A-Za-z]{2,}", "enabled": true, "entityClass": "EMAIL" }, { "type": "regex", "pattern": "https?://[^\\s]+", "enabled": true, "entityClass": "URL" }, { "type": "regex", "pattern": "\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b", "enabled": true, "entityClass": "IP" }, { "type": "ner", "enabled": true } ] ``` 3. Used the assistant (see screenshots below) ### Screenshots <img width="689" alt="image" src="https://github.com/user-attachments/assets/d1f9bd57-7e76-43dc-88a6-d0be5fb15092" /> <img width="689" alt="image" src="https://github.com/user-attachments/assets/ed63626b-b32d-45f8-9cf4-c575320d0dfc" /> <img width="689" alt="image" src="https://github.com/user-attachments/assets/0b591158-9186-406a-aab3-e3be538216dc" /> ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md) - [x] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) (cherry picked from commit 05b4fdd) # Conflicts: # x-pack/platform/packages/shared/kbn-ai-assistant/src/chat/chat_timeline.tsx
4 tasks
Contributor
|
Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant) |
viduni94
approved these changes
Jun 25, 2025
arturoliduena
approved these changes
Jun 25, 2025
Contributor
💚 Build Succeeded
Metrics [docs]Module Count
Async chunks
Page load bundle
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport
This will backport the following commits from
mainto8.19:Questions ?
Please refer to the Backport tool documentation