openai[patch]: fix azure open lc serialization, release 0.1.5 (#21159)

This commit is contained in:
Bagatur
2024-05-01 18:03:29 -04:00
committed by GitHub
parent 94a838740e
commit 6fa8626e2f
6 changed files with 109 additions and 67 deletions

View File

@@ -10,12 +10,12 @@ from langchain_core.outputs import ChatResult
from langchain_core.pydantic_v1 import Field, SecretStr, root_validator
from langchain_core.utils import convert_to_secret_str, get_from_dict_or_env
from langchain_openai.chat_models.base import ChatOpenAI
from langchain_openai.chat_models.base import BaseChatOpenAI
logger = logging.getLogger(__name__)
class AzureChatOpenAI(ChatOpenAI):
class AzureChatOpenAI(BaseChatOpenAI):
"""`Azure OpenAI` Chat Completion API.
To use this class you
@@ -100,6 +100,17 @@ class AzureChatOpenAI(ChatOpenAI):
"""Get the namespace of the langchain object."""
return ["langchain", "chat_models", "azure_openai"]
@property
def lc_secrets(self) -> Dict[str, str]:
return {
"openai_api_key": "AZURE_OPENAI_API_KEY",
"azure_ad_token": "AZURE_OPENAI_AD_TOKEN",
}
@classmethod
def is_lc_serializable(cls) -> bool:
return True
@root_validator()
def validate_environment(cls, values: Dict) -> Dict:
"""Validate that api key and python package exists in environment."""