Skip to content

Commit

Permalink
community[patch]: fix deprecation warnings on openai subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis committed Jan 6, 2024
1 parent 4ac6167 commit cc89e3b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
8 changes: 7 additions & 1 deletion libs/community/langchain_community/chat_models/anyscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import logging
import os
import sys
from typing import TYPE_CHECKING, Dict, Optional, Set
from typing import TYPE_CHECKING, Any, Dict, Optional, Set

import requests
from langchain_core._api.deprecation import suppress_langchain_deprecation_warning
from langchain_core.messages import BaseMessage
from langchain_core.pydantic_v1 import Field, SecretStr, root_validator
from langchain_core.utils import convert_to_secret_str, get_from_dict_or_env
Expand Down Expand Up @@ -72,6 +73,11 @@ def is_lc_serializable(cls) -> bool:
available_models: Optional[Set[str]] = None
"""Available models from Anyscale API."""

def __init__(self, *kwargs: Any) -> None:
# bypass deprecation warning for ChatOpenAI
with suppress_langchain_deprecation_warning():
super().__init__(*kwargs)

@staticmethod
def get_available_models(
anyscale_api_key: Optional[str] = None,
Expand Down
8 changes: 7 additions & 1 deletion libs/community/langchain_community/chat_models/everlyai.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

import logging
import sys
from typing import TYPE_CHECKING, Dict, Optional, Set
from typing import TYPE_CHECKING, Any, Dict, Optional, Set

from langchain_core._api.deprecation import suppress_langchain_deprecation_warning
from langchain_core.messages import BaseMessage
from langchain_core.pydantic_v1 import Field, root_validator
from langchain_core.utils import get_from_dict_or_env
Expand Down Expand Up @@ -64,6 +65,11 @@ def is_lc_serializable(cls) -> bool:
available_models: Optional[Set[str]] = None
"""Available models from EverlyAI API."""

def __init__(self, *kwargs: Any) -> None:
# bypass deprecation warning for ChatOpenAI
with suppress_langchain_deprecation_warning():
super().__init__(*kwargs)

@staticmethod
def get_available_models() -> Set[str]:
"""Get available models from EverlyAI API."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
from typing import Any, Dict, List, Optional

from langchain_core._api.deprecation import suppress_langchain_deprecation_warning
from langchain_core.callbacks import (
AsyncCallbackManagerForLLMRun,
CallbackManagerForLLMRun,
Expand Down Expand Up @@ -39,6 +40,11 @@ class PromptLayerChatOpenAI(ChatOpenAI):
pl_tags: Optional[List[str]]
return_pl_id: Optional[bool] = False

def __init__(self, *kwargs: Any) -> None:
# bypass deprecation warning for ChatOpenAI
with suppress_langchain_deprecation_warning():
super().__init__(*kwargs)

@classmethod
def is_lc_serializable(cls) -> bool:
return False
Expand Down
6 changes: 6 additions & 0 deletions libs/community/langchain_community/llms/promptlayer_openai.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime
from typing import Any, List, Optional

from langchain_core._api.deprecation import suppress_langchain_deprecation_warning
from langchain_core.callbacks import (
AsyncCallbackManagerForLLMRun,
CallbackManagerForLLMRun,
Expand Down Expand Up @@ -37,6 +38,11 @@ class PromptLayerOpenAI(OpenAI):
pl_tags: Optional[List[str]]
return_pl_id: Optional[bool] = False

def __init__(self, *kwargs: Any) -> None:
# bypass deprecation warning for ChatOpenAI
with suppress_langchain_deprecation_warning():
super().__init__(*kwargs)

@classmethod
def is_lc_serializable(cls) -> bool:
return False
Expand Down

0 comments on commit cc89e3b

Please sign in to comment.