From b1cef3099830d843115b7a0c816acfa670fc8edb Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Thu, 13 Jun 2024 12:15:04 -0700 Subject: [PATCH] openai[patch]: Fix tool content list (#5756) * openai[patch]: Fix tool content list * same for func calls * chore: lint files * drop console log --- libs/langchain-openai/src/chat_models.ts | 2 ++ .../src/tests/chat_models.standard.int.test.ts | 6 ------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/libs/langchain-openai/src/chat_models.ts b/libs/langchain-openai/src/chat_models.ts index 243518c41c2d..8282ab235906 100644 --- a/libs/langchain-openai/src/chat_models.ts +++ b/libs/langchain-openai/src/chat_models.ts @@ -228,11 +228,13 @@ function convertMessagesToOpenAIParams(messages: BaseMessage[]) { } if (message.additional_kwargs.function_call != null) { completionParam.function_call = message.additional_kwargs.function_call; + completionParam.content = null; } if (isAIMessage(message) && !!message.tool_calls?.length) { completionParam.tool_calls = message.tool_calls.map( convertLangChainToolCallToOpenAI ); + completionParam.content = null; } else { if (message.additional_kwargs.tool_calls != null) { completionParam.tool_calls = message.additional_kwargs.tool_calls; diff --git a/libs/langchain-openai/src/tests/chat_models.standard.int.test.ts b/libs/langchain-openai/src/tests/chat_models.standard.int.test.ts index 9c0c4e0d90d2..6eb91f093c4c 100644 --- a/libs/langchain-openai/src/tests/chat_models.standard.int.test.ts +++ b/libs/langchain-openai/src/tests/chat_models.standard.int.test.ts @@ -24,12 +24,6 @@ class ChatOpenAIStandardIntegrationTests extends ChatModelIntegrationTests< }); } - async testToolMessageHistoriesListContent() { - console.warn( - "ChatOpenAI testToolMessageHistoriesListContent test known failure. Skipping..." - ); - } - async testUsageMetadataStreaming() { // ChatOpenAI does not support streaming tokens by // default, so we must pass in a call option to