langchain[patch]: Add missing deprecation for openai adapters (#20668)

Add missing deprecation for openai adapters
This commit is contained in:
Eugene Yurtsev 2024-04-22 14:05:55 -04:00 committed by GitHub
parent 38adbfdf34
commit 936c6cc74a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,20 +1,28 @@
from langchain_community.adapters.openai import ( import warnings
Chat,
ChatCompletion, from langchain_core._api import LangChainDeprecationWarning
ChatCompletionChunk,
ChatCompletions, from langchain.utils.interactive_env import is_interactive_env
Choice,
ChoiceChunk,
Completions, def __getattr__(name: str) -> None:
IndexableBaseModel, # If not in interactive env, raise warning.
chat, from langchain_community.adapters import openai
convert_dict_to_message,
convert_message_to_dict, if not is_interactive_env():
convert_messages_for_finetuning, warnings.warn(
convert_openai_messages, "Importing from langchain is deprecated. Importing from "
"langchain will no longer be supported as of langchain==0.2.0. "
"Instead of `from langchain.adapters.openai import {name}` "
"Use `from langchain_community.adapters.openai import {name}`."
"To install langchain-community run `pip install -U langchain-community`.",
category=LangChainDeprecationWarning,
) )
__all__ = [ return getattr(openai, name)
__all__ = [ # noqa: F822
"IndexableBaseModel", "IndexableBaseModel",
"Choice", "Choice",
"ChatCompletions", "ChatCompletions",