Skip to content

Commit

Permalink
Andrew's nits
Browse files Browse the repository at this point in the history
  • Loading branch information
stephmilovic committed May 2, 2024
1 parent 3be4b04 commit dd02014
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ interface GenAiConfig {
export const getGenAiConfig = (connector: ActionConnector | undefined): GenAiConfig | undefined => {
if (!connector?.isPreconfigured) {
const config = (connector as ActionConnectorProps<GenAiConfig, unknown>)?.config;
if (config?.apiProvider === OpenAiProviderType.AzureAi) {
return {
...config,
defaultModel: getAzureApiVersionParameter(config.apiUrl ?? ''),
};
}

return (connector as ActionConnectorProps<GenAiConfig, unknown>)?.config;
const { apiProvider, apiUrl, defaultModel } = config ?? {};

return {
apiProvider,
apiUrl,
defaultModel:
apiProvider === OpenAiProviderType.AzureAi
? getAzureApiVersionParameter(apiUrl ?? '')
: defaultModel,
};
}
return undefined;

return undefined; // the connector is neither available nor editable
};

export const getActionTypeTitle = (actionType: ActionTypeModel): string => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ interface GenAiConfig {
export const getGenAiConfig = (connector: ActionConnector | undefined): GenAiConfig | undefined => {
if (!connector?.isPreconfigured) {
const config = (connector as ActionConnectorProps<GenAiConfig, unknown>)?.config;
if (config?.apiProvider === OpenAiProviderType.AzureAi) {
return {
...config,
defaultModel: getAzureApiVersionParameter(config.apiUrl ?? ''),
};
}
const { apiProvider, apiUrl, defaultModel } = config ?? {};

return (connector as ActionConnectorProps<GenAiConfig, unknown>)?.config;
return {
apiProvider,
apiUrl,
defaultModel:
apiProvider === OpenAiProviderType.AzureAi
? getAzureApiVersionParameter(apiUrl ?? '')
: defaultModel,
};
}
return undefined;

return undefined; // the connector is neither available nor editable
};

const getAzureApiVersionParameter = (url: string): string | undefined => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
useAssistantContext,
useLoadConnectors,
} from '@kbn/elastic-assistant';
import { uniq } from 'lodash';
import { uniq } from 'lodash/fp';
import type { AttackDiscoveryPostRequestBody, Replacements } from '@kbn/elastic-assistant-common';
import {
AttackDiscoveryPostResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const insightsGeneratedEvent: TelemetryEvent = {
alertsCount: {
type: 'integer',
_meta: {
description: 'Number of alerts evaluated',
description: 'Number of unique alerts referenced in the attack discoveries',
optional: false,
},
},
Expand Down

0 comments on commit dd02014

Please sign in to comment.