diff --git a/x-pack/plugins/actions/server/integration_tests/__snapshots__/connector_types.test.ts.snap b/x-pack/plugins/actions/server/integration_tests/__snapshots__/connector_types.test.ts.snap index 6e4392e3f737e3..c52ef2f2f64780 100644 --- a/x-pack/plugins/actions/server/integration_tests/__snapshots__/connector_types.test.ts.snap +++ b/x-pack/plugins/actions/server/integration_tests/__snapshots__/connector_types.test.ts.snap @@ -1083,51 +1083,14 @@ Object { "keys": Object { "content": Object { "flags": Object { - "default": [Function], "error": [Function], - "presence": "optional", }, "metas": Array [ Object { - "x-oas-optional": true, - }, - ], - "rules": Array [ - Object { - "args": Object { - "method": [Function], - }, - "name": "custom", - }, - ], - "type": "string", - }, - "rawContent": Object { - "flags": Object { - "default": [Function], - "error": [Function], - "presence": "optional", - }, - "items": Array [ - Object { - "flags": Object { - "error": [Function], - "presence": "optional", - }, - "metas": Array [ - Object { - "x-oas-any-type": true, - }, - ], - "type": "any", - }, - ], - "metas": Array [ - Object { - "x-oas-optional": true, + "x-oas-any-type": true, }, ], - "type": "array", + "type": "any", }, "role": Object { "flags": Object { @@ -1144,14 +1107,6 @@ Object { "type": "string", }, }, - "rules": Array [ - Object { - "args": Object { - "method": [Function], - }, - "name": "custom", - }, - ], "type": "object", }, ], diff --git a/x-pack/plugins/stack_connectors/common/bedrock/schema.ts b/x-pack/plugins/stack_connectors/common/bedrock/schema.ts index 03f4f5cc01735d..15ac45c0cf5973 100644 --- a/x-pack/plugins/stack_connectors/common/bedrock/schema.ts +++ b/x-pack/plugins/stack_connectors/common/bedrock/schema.ts @@ -78,7 +78,12 @@ export const InvokeAIActionResponseSchema = schema.object({ }); export const InvokeAIRawActionParamsSchema = schema.object({ - messages: schema.arrayOf(BedrockMessageSchema), + messages: schema.arrayOf( + schema.object({ + role: schema.string(), + content: schema.any(), + }) + ), model: schema.maybe(schema.string()), temperature: schema.maybe(schema.number()), stopSequences: schema.maybe(schema.arrayOf(schema.string())), diff --git a/x-pack/plugins/stack_connectors/common/bedrock/types.ts b/x-pack/plugins/stack_connectors/common/bedrock/types.ts index 3b02f40d2de62a..9d742e5f892a81 100644 --- a/x-pack/plugins/stack_connectors/common/bedrock/types.ts +++ b/x-pack/plugins/stack_connectors/common/bedrock/types.ts @@ -35,5 +35,5 @@ export type RunActionResponse = TypeOf; export type StreamingResponse = TypeOf; export type DashboardActionParams = TypeOf; export type DashboardActionResponse = TypeOf; -export type BedRockMessage = TypeOf; +export type BedrockMessage = TypeOf; export type BedrockToolChoice = TypeOf; diff --git a/x-pack/plugins/stack_connectors/server/connector_types/bedrock/bedrock.ts b/x-pack/plugins/stack_connectors/server/connector_types/bedrock/bedrock.ts index c2c773bdeaf87f..9bd5c64404f64f 100644 --- a/x-pack/plugins/stack_connectors/server/connector_types/bedrock/bedrock.ts +++ b/x-pack/plugins/stack_connectors/server/connector_types/bedrock/bedrock.ts @@ -32,7 +32,7 @@ import type { InvokeAIRawActionParams, InvokeAIRawActionResponse, RunApiLatestResponse, - BedRockMessage, + BedrockMessage, BedrockToolChoice, } from '../../../common/bedrock/types'; import { @@ -422,7 +422,7 @@ const formatBedrockBody = ({ tools, toolChoice, }: { - messages: BedRockMessage[]; + messages: BedrockMessage[]; stopSequences?: string[]; temperature?: number; maxTokens?: number; @@ -440,9 +440,9 @@ const formatBedrockBody = ({ tool_choice: toolChoice, }); -interface FormattedBedRockMessage { +interface FormattedBedrockMessage { role: string; - content: string | BedRockMessage['rawContent']; + content: string | BedrockMessage['rawContent']; } /** @@ -452,15 +452,15 @@ interface FormattedBedRockMessage { * @param messages */ const ensureMessageFormat = ( - messages: BedRockMessage[], + messages: BedrockMessage[], systemPrompt?: string ): { - messages: FormattedBedRockMessage[]; + messages: FormattedBedrockMessage[]; system?: string; } => { let system = systemPrompt ? systemPrompt : ''; - const newMessages = messages.reduce((acc, m) => { + const newMessages = messages.reduce((acc, m) => { if (m.role === 'system') { system = `${system.length ? `${system}\n` : ''}${m.content}`; return acc;