Skip to content

Commit

Permalink
Adds deprecation warning when passing chat models into OpenAI LLM con…
Browse files Browse the repository at this point in the history
…structors (#6136)
  • Loading branch information
jacoblee93 committed Jul 18, 2024
1 parent 3084c69 commit 2f6894b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libs/langchain-openai/src/llms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ export class OpenAI<CallOptions extends OpenAICallOptions = OpenAICallOptions>
(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,
Expand Down

0 comments on commit 2f6894b

Please sign in to comment.