Skip to content

Commit

Permalink
Changes for Patrick
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed Jun 5, 2023
1 parent 38ff3c3 commit e2c5818
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions x-pack/plugins/actions/server/lib/action_executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,12 @@ export class ActionExecutor {

event.event = event.event || {};

// start gen_ai extension
// add event.kibana.action.execution.gen_ai to event log when GenerativeAi Connector is executed
if (result.status === 'ok' && actionTypeId === '.gen-ai') {
const data = result.data as unknown as { usage: {} };
const data = result.data as unknown as {
usage: { prompt_tokens: number; completion_tokens: number; total_tokens: number };
};
event.kibana = event.kibana || {};
event.kibana.action = event.kibana.action || {};
event.kibana = {
Expand All @@ -265,13 +268,20 @@ export class ActionExecutor {
execution: {
...event.kibana.action.execution,
gen_ai: {
usage: data.usage,
usage: {
total_tokens: data.usage.total_tokens,

This comment has been minimized.

Copy link
@pmuellr

pmuellr Jun 5, 2023

Member

I think we need to check data usage, in case it's null/undefined - I think prolly just data.usage?.total_token usage is good enough for the three properties ...

prompt_tokens: data.usage.prompt_tokens,
completion_tokens: data.usage.completion_tokens,
},
},
},
},
};
}
const currentUser = await security?.authc.getCurrentUser(request);
// end gen_ai extension

const currentUser = security?.authc.getCurrentUser(request);

event.user = event.user || {};
event.user.name = currentUser?.username;
event.user.id = currentUser?.profile_uid;
Expand Down

0 comments on commit e2c5818

Please sign in to comment.