mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-17 07:26:16 +00:00
Do not issue beta or deprecation warnings on internal calls (#15641)
This commit is contained in:
@@ -56,7 +56,7 @@ from langchain_core.caches import RETURN_VAL_TYPE, BaseCache
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.language_models.llms import LLM, get_prompts
|
||||
from langchain_core.load.dump import dumps
|
||||
from langchain_core.load.load import _loads_suppress_warning
|
||||
from langchain_core.load.load import loads
|
||||
from langchain_core.outputs import ChatGeneration, Generation
|
||||
from langchain_core.utils import get_from_env
|
||||
|
||||
@@ -149,10 +149,7 @@ def _loads_generations(generations_str: str) -> Union[RETURN_VAL_TYPE, None]:
|
||||
RETURN_VAL_TYPE: A list of generations.
|
||||
"""
|
||||
try:
|
||||
generations = [
|
||||
_loads_suppress_warning(_item_str)
|
||||
for _item_str in json.loads(generations_str)
|
||||
]
|
||||
generations = [loads(_item_str) for _item_str in json.loads(generations_str)]
|
||||
return generations
|
||||
except (json.JSONDecodeError, TypeError):
|
||||
# deferring the (soft) handling to after the legacy-format attempt
|
||||
@@ -227,7 +224,7 @@ class SQLAlchemyCache(BaseCache):
|
||||
rows = session.execute(stmt).fetchall()
|
||||
if rows:
|
||||
try:
|
||||
return [_loads_suppress_warning(row[0]) for row in rows]
|
||||
return [loads(row[0]) for row in rows]
|
||||
except Exception:
|
||||
logger.warning(
|
||||
"Retrieving a cache value that could not be deserialized "
|
||||
@@ -398,7 +395,7 @@ class RedisCache(BaseCache):
|
||||
if results:
|
||||
for _, text in results.items():
|
||||
try:
|
||||
generations.append(_loads_suppress_warning(text))
|
||||
generations.append(loads(text))
|
||||
except Exception:
|
||||
logger.warning(
|
||||
"Retrieving a cache value that could not be deserialized "
|
||||
@@ -538,9 +535,7 @@ class RedisSemanticCache(BaseCache):
|
||||
if results:
|
||||
for document in results:
|
||||
try:
|
||||
generations.extend(
|
||||
_loads_suppress_warning(document.metadata["return_val"])
|
||||
)
|
||||
generations.extend(loads(document.metadata["return_val"]))
|
||||
except Exception:
|
||||
logger.warning(
|
||||
"Retrieving a cache value that could not be deserialized "
|
||||
@@ -1190,7 +1185,7 @@ class SQLAlchemyMd5Cache(BaseCache):
|
||||
"""Look up based on prompt and llm_string."""
|
||||
rows = self._search_rows(prompt, llm_string)
|
||||
if rows:
|
||||
return [_loads_suppress_warning(row[0]) for row in rows]
|
||||
return [loads(row[0]) for row in rows]
|
||||
return None
|
||||
|
||||
def update(self, prompt: str, llm_string: str, return_val: RETURN_VAL_TYPE) -> None:
|
||||
|
@@ -4,7 +4,7 @@ import logging
|
||||
from typing import TYPE_CHECKING, Dict, Iterable, Iterator, List, Optional, Union, cast
|
||||
|
||||
from langchain_core.chat_sessions import ChatSession
|
||||
from langchain_core.load.load import _load_suppress_warning
|
||||
from langchain_core.load.load import load
|
||||
|
||||
from langchain_community.chat_loaders.base import BaseChatLoader
|
||||
|
||||
@@ -66,10 +66,8 @@ class LangSmithRunChatLoader(BaseChatLoader):
|
||||
raise ValueError(f"Run has no 'messages' inputs. Got {llm_run.inputs}")
|
||||
if not llm_run.outputs:
|
||||
raise ValueError("Cannot convert pending run")
|
||||
messages = _load_suppress_warning(llm_run.inputs)["messages"]
|
||||
message_chunk = _load_suppress_warning(llm_run.outputs)["generations"][0][
|
||||
"message"
|
||||
]
|
||||
messages = load(llm_run.inputs)["messages"]
|
||||
message_chunk = load(llm_run.outputs)["generations"][0]["message"]
|
||||
return ChatSession(messages=messages + [message_chunk])
|
||||
|
||||
@staticmethod
|
||||
|
@@ -4,10 +4,9 @@ from __future__ import annotations
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Set
|
||||
from typing import TYPE_CHECKING, 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
|
||||
@@ -73,11 +72,6 @@ class ChatAnyscale(ChatOpenAI):
|
||||
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,
|
||||
|
@@ -3,9 +3,8 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import sys
|
||||
from typing import TYPE_CHECKING, Any, Dict, Optional, Set
|
||||
from typing import TYPE_CHECKING, 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
|
||||
@@ -65,11 +64,6 @@ class ChatEverlyAI(ChatOpenAI):
|
||||
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."""
|
||||
|
@@ -2,7 +2,6 @@
|
||||
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,
|
||||
@@ -40,11 +39,6 @@ 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
|
||||
|
@@ -1,7 +1,6 @@
|
||||
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,
|
||||
@@ -38,11 +37,6 @@ 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
|
||||
|
Reference in New Issue
Block a user