Skip to content

Commit 1b2f09c

Browse files
authored
[Security Solutions] fix defend insights evaluations (#221112)
## Summary Fixes an issue where defend insights evaluations always returned no insights resulting in a score of 0. The `anonymizedEvents` key was renamed to `anonymizedDocuments` in [this PR](#216757). The relevant datasets have already been updated in langsmith. ### Checklist - [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
1 parent ce1d898 commit 1b2f09c

4 files changed

Lines changed: 10 additions & 10 deletions

File tree

x-pack/solutions/security/plugins/elastic_assistant/server/lib/defend_insights/evaluation/example_input/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const mockDefendInsight = {
2626
const validInput = {
2727
insights: [mockDefendInsight],
2828
prompt: 'test prompt',
29-
anonymizedEvents: [
29+
anonymizedDocuments: [
3030
{
3131
pageContent: 'event content',
3232
metadata: {

x-pack/solutions/security/plugins/elastic_assistant/server/lib/defend_insights/evaluation/example_input/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const Document = z.object({
1616
export const ExampleDefendInsightsInput = z.object({
1717
insights: z.array(DefendInsight).nullable().optional(),
1818
prompt: z.string().optional(),
19-
anonymizedEvents: z.array(Document).optional(),
19+
anonymizedDocuments: z.array(Document).optional(),
2020
combinedGenerations: z.string().optional(),
2121
combinedRefinements: z.string().optional(),
2222
errors: z.array(z.string()).optional(),

x-pack/solutions/security/plugins/elastic_assistant/server/lib/defend_insights/evaluation/helpers/get_graph_input_overrides/index.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ const mockReplacements = {
2020
};
2121

2222
describe('getDefendInsightsGraphInputOverrides', () => {
23-
it('should return root-level anonymizedEvents and replacements plus overrides', () => {
23+
it('should return root-level anonymizedDocuments and replacements plus overrides', () => {
2424
const input = {
25-
anonymizedEvents: [mockDoc],
25+
anonymizedDocuments: [mockDoc],
2626
replacements: mockReplacements,
2727
overrides: {
2828
prompt: 'new prompt',
@@ -34,7 +34,7 @@ describe('getDefendInsightsGraphInputOverrides', () => {
3434
const result = getDefendInsightsGraphInputOverrides(input);
3535

3636
expect(result).toEqual({
37-
anonymizedEvents: [mockDoc],
37+
anonymizedDocuments: [mockDoc],
3838
replacements: mockReplacements,
3939
prompt: 'new prompt',
4040
generationAttempts: 2,
@@ -43,14 +43,14 @@ describe('getDefendInsightsGraphInputOverrides', () => {
4343

4444
it('should return only picked values when no overrides are present', () => {
4545
const input = {
46-
anonymizedEvents: [mockDoc],
46+
anonymizedDocuments: [mockDoc],
4747
replacements: mockReplacements,
4848
};
4949

5050
const result = getDefendInsightsGraphInputOverrides(input);
5151

5252
expect(result).toEqual({
53-
anonymizedEvents: [mockDoc],
53+
anonymizedDocuments: [mockDoc],
5454
replacements: mockReplacements,
5555
});
5656
});

x-pack/solutions/security/plugins/elastic_assistant/server/lib/defend_insights/evaluation/helpers/get_graph_input_overrides/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export const getDefendInsightsGraphInputOverrides = (
2222

2323
// return all overrides at the root level:
2424
return {
25-
// pick extracts just the anonymizedEvents and replacements from the root level of the input,
26-
// and only adds the anonymizedEvents key if it exists in the input
27-
...pick('anonymizedEvents', validatedInput),
25+
// pick extracts just the anonymizedDocuments and replacements from the root level of the input,
26+
// and only adds the anonymizedDocuments key if it exists in the input
27+
...pick('anonymizedDocuments', validatedInput),
2828
...pick('replacements', validatedInput),
2929
...overrides, // bring all other overrides to the root level
3030
};

0 commit comments

Comments
 (0)