From 2f6894b765d413bb9ad11532de0fdab8c8c42861 Mon Sep 17 00:00:00 2001 From: Jacob Lee Date: Thu, 18 Jul 2024 12:04:09 -0700 Subject: [PATCH] Adds deprecation warning when passing chat models into OpenAI LLM constructors (#6136) --- libs/langchain-openai/src/llms.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libs/langchain-openai/src/llms.ts b/libs/langchain-openai/src/llms.ts index 871a51500b2f..d234f77e7e3d 100644 --- a/libs/langchain-openai/src/llms.ts +++ b/libs/langchain-openai/src/llms.ts @@ -175,6 +175,17 @@ export class OpenAI (model?.startsWith("gpt-3.5-turbo") || model?.startsWith("gpt-4")) && !model?.includes("-instruct") ) { + console.warn( + [ + `Your chosen OpenAI model, "${model}", is a chat model and not a text-in/text-out LLM.`, + `Passing it into the "OpenAI" class is deprecated and only permitted for backwards-compatibility. You may experience odd behavior.`, + `Please use the "ChatOpenAI" class instead.`, + "", + `See this page for more information:`, + "|", + `└> https://js.langchain.com/v0.2/docs/integrations/chat/openai`, + ].join("\n") + ); // eslint-disable-next-line no-constructor-return return new OpenAIChat( fields,