From 2ffd2b720a03a45394db46749cf1186ac3c9a60a Mon Sep 17 00:00:00 2001 From: bracesproul Date: Thu, 13 Jun 2024 11:28:29 -0700 Subject: [PATCH 1/4] openai[patch]: Fix tool content list --- 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..4c7bb9aedb45 100644 --- a/libs/langchain-openai/src/chat_models.ts +++ b/libs/langchain-openai/src/chat_models.ts @@ -233,6 +233,7 @@ function convertMessagesToOpenAIParams(messages: BaseMessage[]) { 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; @@ -948,6 +949,7 @@ export class ChatOpenAI< const requestOptions = this._getClientOptions(options); return this.caller.call(async () => { try { + console.log(request.messages) const res = await this.client.chat.completions.create( request, requestOptions 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 From 7100ef51239bc00634037e056b8e0b05bc3d7407 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Thu, 13 Jun 2024 11:29:17 -0700 Subject: [PATCH 2/4] same for func calls --- libs/langchain-openai/src/chat_models.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/langchain-openai/src/chat_models.ts b/libs/langchain-openai/src/chat_models.ts index 4c7bb9aedb45..b3ad8840d4bb 100644 --- a/libs/langchain-openai/src/chat_models.ts +++ b/libs/langchain-openai/src/chat_models.ts @@ -228,6 +228,7 @@ 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( From 2a51525325e4e122f1ffb2def71113469385238e Mon Sep 17 00:00:00 2001 From: bracesproul Date: Thu, 13 Jun 2024 11:29:27 -0700 Subject: [PATCH 3/4] chore: lint files --- libs/langchain-openai/src/chat_models.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/langchain-openai/src/chat_models.ts b/libs/langchain-openai/src/chat_models.ts index b3ad8840d4bb..9c532c1245e2 100644 --- a/libs/langchain-openai/src/chat_models.ts +++ b/libs/langchain-openai/src/chat_models.ts @@ -950,7 +950,7 @@ export class ChatOpenAI< const requestOptions = this._getClientOptions(options); return this.caller.call(async () => { try { - console.log(request.messages) + console.log(request.messages); const res = await this.client.chat.completions.create( request, requestOptions From e8c875b0d1e9e3488a40814e32d18d78de9e6956 Mon Sep 17 00:00:00 2001 From: bracesproul Date: Thu, 13 Jun 2024 11:29:59 -0700 Subject: [PATCH 4/4] drop console log --- libs/langchain-openai/src/chat_models.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/libs/langchain-openai/src/chat_models.ts b/libs/langchain-openai/src/chat_models.ts index 9c532c1245e2..8282ab235906 100644 --- a/libs/langchain-openai/src/chat_models.ts +++ b/libs/langchain-openai/src/chat_models.ts @@ -950,7 +950,6 @@ export class ChatOpenAI< const requestOptions = this._getClientOptions(options); return this.caller.call(async () => { try { - console.log(request.messages); const res = await this.client.chat.completions.create( request, requestOptions