diff --git a/libs/langchain-google-common/src/chat_models.ts b/libs/langchain-google-common/src/chat_models.ts index 207490cd3077..8d3884e94295 100644 --- a/libs/langchain-google-common/src/chat_models.ts +++ b/libs/langchain-google-common/src/chat_models.ts @@ -117,8 +117,15 @@ class ChatConnection extends AbstractGoogleLLMConnection< } // Combine adjacent function messages - if (cur[0]?.role === "function" && acc.length > 0 && acc[acc.length - 1].role === "function") { - acc[acc.length - 1].parts = [...acc[acc.length - 1].parts, ...cur[0].parts]; + if ( + cur[0]?.role === "function" && + acc.length > 0 && + acc[acc.length - 1].role === "function" + ) { + acc[acc.length - 1].parts = [ + ...acc[acc.length - 1].parts, + ...cur[0].parts, + ]; } else { acc.push(...cur); }