Skip to content

Commit

Permalink
community[patch]: fix deprecation warnings on openai subclasses (#15621)
Browse files Browse the repository at this point in the history
  • Loading branch information
efriis authored Jan 6, 2024
1 parent 4ac6167 commit d136925
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 88 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
99 changes: 15 additions & 84 deletions libs/langchain/poetry.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion libs/langchain/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ pytest-socket = "^0.6.0"
syrupy = "^4.0.2"
requests-mock = "^1.11.0"
langchain-core = {path = "../core", develop = true}
langchain-openai = {path = "../partners/openai", develop = true}

[tool.poetry.group.codespell]
optional = true
Expand Down
1 change: 0 additions & 1 deletion libs/langchain/tests/unit_tests/test_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ def test_test_group_dependencies(poetry_conf: Mapping[str, Any]) -> None:
"duckdb-engine",
"freezegun",
"langchain-core",
"langchain-openai",
"lark",
"pandas",
"pytest",
Expand Down

0 comments on commit d136925

Please sign in to comment.