88 Params ,
99 Tool ,
1010 ToolCall ,
11+ SYSTEM_MESSAGE_ROLES ,
1112} from '../../types/requestBody' ;
1213import {
1314 AnthropicChatCompleteResponse ,
@@ -71,7 +72,7 @@ export const VertexGoogleChatCompleteConfig: ProviderConfig = {
7172 // From gemini-1.5 onwards, systemInstruction is supported
7273 // Skipping system message and sending it in systemInstruction for gemini 1.5 models
7374 if (
74- message . role === 'system' &&
75+ SYSTEM_MESSAGE_ROLES . includes ( message . role ) &&
7576 ! SYSTEM_INSTRUCTION_DISABLED_MODELS . includes ( params . model as string )
7677 )
7778 return ;
@@ -186,7 +187,7 @@ export const VertexGoogleChatCompleteConfig: ProviderConfig = {
186187 if ( ! firstMessage ) return ;
187188
188189 if (
189- firstMessage . role === 'system' &&
190+ SYSTEM_MESSAGE_ROLES . includes ( firstMessage . role ) &&
190191 typeof firstMessage . content === 'string'
191192 ) {
192193 return {
@@ -200,7 +201,7 @@ export const VertexGoogleChatCompleteConfig: ProviderConfig = {
200201 }
201202
202203 if (
203- firstMessage . role === 'system' &&
204+ SYSTEM_MESSAGE_ROLES . includes ( firstMessage . role ) &&
204205 typeof firstMessage . content === 'object' &&
205206 firstMessage . content ?. [ 0 ] ?. text
206207 ) {
@@ -413,7 +414,7 @@ export const VertexAnthropicChatCompleteConfig: ProviderConfig = {
413414 // Transform the chat messages into a simple prompt
414415 if ( ! ! params . messages ) {
415416 params . messages . forEach ( ( msg ) => {
416- if ( msg . role === 'system' ) return ;
417+ if ( SYSTEM_MESSAGE_ROLES . includes ( msg . role ) ) return ;
417418
418419 if ( msg . role === 'assistant' ) {
419420 messages . push ( transformAssistantMessageForAnthropic ( msg ) ) ;
@@ -481,14 +482,14 @@ export const VertexAnthropicChatCompleteConfig: ProviderConfig = {
481482 if ( ! ! params . messages ) {
482483 params . messages . forEach ( ( msg ) => {
483484 if (
484- msg . role === 'system' &&
485+ SYSTEM_MESSAGE_ROLES . includes ( msg . role ) &&
485486 msg . content &&
486487 typeof msg . content === 'object' &&
487488 msg . content [ 0 ] . text
488489 ) {
489490 systemMessage = msg . content [ 0 ] . text ;
490491 } else if (
491- msg . role === 'system' &&
492+ SYSTEM_MESSAGE_ROLES . includes ( msg . role ) &&
492493 typeof msg . content === 'string'
493494 ) {
494495 systemMessage = msg . content ;
0 commit comments