Skip to content

[8.19] [Obs AI Assistant] Anonymization support (#223351) #224100

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

Merged
merged 3 commits into from
Jun 16, 2025

Conversation

neptunian
Copy link
Contributor

Backport

This will backport the following commits from main to 8.19:

Questions ?

Please refer to the Backport tool documentation

Re-submit of elastic#216352 as it has
merge conflicts and we don't have write permissions for Sandra's remote.

To test, add the following to your kibana.yml:

```
uiSettings:
  overrides:
    "observability:aiAssistantAnonymizationRules":
      - id: "ner"
        type: "ner"
        enabled: true
      - id: "beach"
        type: "regex"
        enabled: true
        pattern: "sandy"
```

---------

Co-authored-by: Sandra Gonzales <sandra.gonzales@elastic.co>
Co-authored-by: Sandra G <neptunian@users.noreply.github.com>
(cherry picked from commit 71ec37a)

# Conflicts:
#	x-pack/platform/packages/shared/kbn-ai-assistant/src/chat/chat_timeline.tsx
#	x-pack/platform/plugins/shared/observability_ai_assistant/server/service/client/index.ts
@neptunian neptunian requested a review from kibanamachine as a code owner June 16, 2025 16:06
@neptunian neptunian enabled auto-merge (squash) June 16, 2025 16:06
@botelastic botelastic bot added the Team:Obs AI Assistant Observability AI Assistant label Jun 16, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ai-assistant (Team:Obs AI Assistant)

@neptunian neptunian force-pushed the backport/8.19/pr-223351 branch from ecb5e38 to 8dd1022 Compare June 16, 2025 16:43
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
observabilityAIAssistant 109 110 +1

Public APIs missing comments

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
observabilityAIAssistant 427 443 +16

Async chunks

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

id before after diff
observabilityAIAssistantApp 274.4KB 275.4KB +1014.0B
searchAssistant 175.8KB 176.8KB +1008.0B
total +2.0KB

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
observabilityAIAssistant 27 30 +3

Page load bundle

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

id before after diff
observabilityAIAssistant 42.7KB 43.1KB +485.0B
Unknown metric groups

API count

id before after diff
observabilityAIAssistant 429 447 +18

History

@@ -27,7 +27,19 @@ import { ChatItemActions } from './chat_item_actions';
import { ChatItemAvatar } from './chat_item_avatar';
import { ChatItemContentInlinePromptEditor } from './chat_item_content_inline_prompt_editor';
import { ChatTimelineItem } from './chat_timeline';

// Helper function to extract plain text from a React node.
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
// Helper function to extract plain text from a React node.
// Helper function to extract plain text from a React node.

return extractTextFromReactNode(node.props.children);
}
return '';
}
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
}
}

parts.push(content.substring(lastIndex));
}
return parts;
}
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
}
}

import { DetectedEntity } from '../../types';
/** Regex matching object‑hash placeholders (40 hex chars) */
export const HASH_REGEX = /[0-9a-f]{40}/g;
/**
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
/**
/**

})
from(this.dependencies.anonymizationService.redactMessages(messages)).pipe(
switchMap(({ redactedMessages }) => {
this.dependencies.logger.debug(
Copy link
Contributor

Choose a reason for hiding this comment

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

We can remove this debug line I think as it's the same as the debug line in L496


return redacted;
}
/**
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
/**
/**

@@ -35,7 +35,16 @@ export type ChatCompletionMessageEvent<TToolOptions extends ToolOptions = ToolOp
toolCalls: ToolCallsOf<TToolOptions>['toolCalls'];
}
>;

// with unredactions
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
// with unredactions
// with unredactions

class_name: string;
hash: string;
}>;
}
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
}
}

}
return { unredactedMessages: messages };
}
unredactChatCompletionEvent(): OperatorFunction<
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
unredactChatCompletionEvent(): OperatorFunction<
unredactChatCompletionEvent(): OperatorFunction<

content: message.message.content,
};
}
export function getRedactableMessageEventParts(event: ChatCompletionMessageEvent) {
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
export function getRedactableMessageEventParts(event: ChatCompletionMessageEvent) {
export function getRedactableMessageEventParts(event: ChatCompletionMessageEvent) {

@neptunian neptunian merged commit aac6c9e into elastic:8.19 Jun 16, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Obs AI Assistant Observability AI Assistant
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants