-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Security solution] Implement dashboard to track Gen AI Token Usage #159075
Merged
Merged
Changes from all commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
1a99899
wip
stephmilovic aa9dfb7
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 06843a0
wip user name
stephmilovic a0625be
Merge branch 'gen_ai_tokens' of github.com:stephmilovic/kibana into g…
stephmilovic 8161281
merge main
stephmilovic c99edf9
add user name to event log on gen ai events
stephmilovic 388e8fa
add tests
stephmilovic fde9446
add comment
stephmilovic 6f898c1
Merge branch 'main' into gen_ai_tokens
stephmilovic 43181f1
rm silly line
stephmilovic c3a323b
remove imports from stack-connectors
stephmilovic c18afc0
Update action_executor.ts
stephmilovic 31d69cc
update user
stephmilovic ce09752
add user to every event log event
stephmilovic 45a32da
Merge branch 'main' into gen_ai_tokens
kibanamachine 293c846
Merge remote-tracking branch 'upstream/main' into gen_ai_tokens
stephmilovic 38ff3c3
fix bad name
stephmilovic 57a0e07
ys
stephmilovic e2c5818
Changes for Patrick
stephmilovic 332e404
Merge remote-tracking branch 'upstream/main' into gen_ai_tokens
stephmilovic 797b147
Merge branch 'gen_ai_tokens' into token_lens
stephmilovic 3da6f77
wip still
stephmilovic 98bbc5a
wip still
stephmilovic 2872be8
one more
stephmilovic 1926ef3
Merge branch 'gen_ai_tokens' into token_lens
stephmilovic b38ef81
add usage dashboard to gen ai connector
stephmilovic 2c87991
Merge branch 'main' into token_lens
stephmilovic 2067313
rm console logs
stephmilovic 8cf01ad
rm more logs
stephmilovic 1f6a939
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine c0e276c
update translation
stephmilovic 0d123e5
by title
stephmilovic 024e3d2
?
stephmilovic bf86ce8
Merge branch 'token_lens' of github.com:stephmilovic/kibana into toke…
stephmilovic cfad2b1
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine c5cb490
fix type
stephmilovic 885ebf7
fix broken tests
stephmilovic 98f07fc
Merge branch 'token_lens' of github.com:stephmilovic/kibana into toke…
stephmilovic f3ec82a
Merge branch 'main' into token_lens
stephmilovic 3fe2cc8
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 7ccef4b
fix type
stephmilovic cfd339b
Merge branch 'token_lens' of github.com:stephmilovic/kibana into toke…
stephmilovic 4d5740a
WIP big refactor
stephmilovic a193923
fix
stephmilovic 85b4ca3
much better now
stephmilovic 55ac05f
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine f88f804
rm console logs
stephmilovic 01e4edf
Merge branch 'main' into token_lens
stephmilovic ac58449
fixes
stephmilovic 5da2400
Merge branch 'token_lens' of github.com:stephmilovic/kibana into toke…
stephmilovic fe65eee
fix import
stephmilovic ccb187b
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine b5974cd
better naming
stephmilovic 12fa944
Merge branch 'token_lens' of github.com:stephmilovic/kibana into toke…
stephmilovic 6253899
more fix
stephmilovic 7c35011
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 7964825
add more tests
stephmilovic eb58c26
complete client side testing
stephmilovic 1ca9b91
Merge branch 'token_lens' of github.com:stephmilovic/kibana into toke…
stephmilovic 3d74443
rm silly
stephmilovic 1499627
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 85e686a
more tests
stephmilovic f241d89
Merge branch 'token_lens' of github.com:stephmilovic/kibana into toke…
stephmilovic 4fc2103
api tests
stephmilovic 3d31027
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine ccb4f5d
add doc markdown panel to dashboard
stephmilovic 51bdfd1
Merge branch 'token_lens' of github.com:stephmilovic/kibana into toke…
stephmilovic 7f4e2e2
better div height
stephmilovic e2f4028
test and log changes!
stephmilovic b66d0a8
add comment to other code that threw me
stephmilovic 41b139b
add retry for tests
stephmilovic 8f8f920
fix tests
stephmilovic 40ebeec
rm logs
stephmilovic f5d160d
Merge branch 'main' into token_lens
stephmilovic 76ea01d
Merge branch 'main' into token_lens
kibanamachine cf961aa
test fixed
stephmilovic fcf019a
Merge branch 'token_lens' of github.com:stephmilovic/kibana into toke…
stephmilovic 1101190
i hope this is it!
stephmilovic 2478a53
fix and test
stephmilovic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
37 changes: 37 additions & 0 deletions
37
x-pack/plugins/stack_connectors/public/connector_types/gen_ai/api.test.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { httpServiceMock } from '@kbn/core-http-browser-mocks'; | ||
import { getDashboard } from './api'; | ||
import { SUB_ACTION } from '../../../common/gen_ai/constants'; | ||
const response = { | ||
available: true, | ||
}; | ||
|
||
describe('Gen AI Dashboard API', () => { | ||
const http = httpServiceMock.createStartContract(); | ||
|
||
beforeEach(() => jest.resetAllMocks()); | ||
describe('getDashboard', () => { | ||
test('should call get dashboard API', async () => { | ||
const abortCtrl = new AbortController(); | ||
http.post.mockResolvedValueOnce(response); | ||
const res = await getDashboard({ | ||
http, | ||
signal: abortCtrl.signal, | ||
connectorId: 'te/st', | ||
dashboardId: 'cool-dashboard', | ||
}); | ||
|
||
expect(res).toEqual(response); | ||
expect(http.post).toHaveBeenCalledWith('/api/actions/connector/te%2Fst/_execute', { | ||
body: `{"params":{"subAction":"${SUB_ACTION.DASHBOARD}","subActionParams":{"dashboardId":"cool-dashboard"}}}`, | ||
signal: abortCtrl.signal, | ||
}); | ||
}); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
x-pack/plugins/stack_connectors/public/connector_types/gen_ai/api.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { HttpSetup } from '@kbn/core-http-browser'; | ||
import { ActionTypeExecutorResult, BASE_ACTION_API_PATH } from '@kbn/actions-plugin/common'; | ||
import { SUB_ACTION } from '../../../common/gen_ai/constants'; | ||
import { ConnectorExecutorResult, rewriteResponseToCamelCase } from '../lib/rewrite_response_body'; | ||
|
||
export async function getDashboard({ | ||
http, | ||
signal, | ||
dashboardId, | ||
connectorId, | ||
}: { | ||
http: HttpSetup; | ||
signal: AbortSignal; | ||
connectorId: string; | ||
dashboardId: string; | ||
}): Promise<ActionTypeExecutorResult<{ available: boolean }>> { | ||
const res = await http.post<ConnectorExecutorResult<{ available: boolean }>>( | ||
`${BASE_ACTION_API_PATH}/connector/${encodeURIComponent(connectorId)}/_execute`, | ||
{ | ||
body: JSON.stringify({ | ||
params: { subAction: SUB_ACTION.DASHBOARD, subActionParams: { dashboardId } }, | ||
}), | ||
signal, | ||
} | ||
); | ||
return rewriteResponseToCamelCase(res); | ||
} |
This file contains 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
Oops, something went wrong.
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.
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.
Need to add these services to the sub action connector to give to GenAI to use to check index permissions (esClient) create dashboard (savedObjectsClient)