diff --git a/libs/langchain/langchain/chains/llm.py b/libs/langchain/langchain/chains/llm.py index c32858d97e..1f251a677b 100644 --- a/libs/langchain/langchain/chains/llm.py +++ b/libs/langchain/langchain/chains/llm.py @@ -42,8 +42,8 @@ class LLMChain(Chain): llm = LLMChain(llm=OpenAI(), prompt=prompt) """ - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(self) -> bool: return True prompt: BasePromptTemplate diff --git a/libs/langchain/langchain/chat_models/anthropic.py b/libs/langchain/langchain/chat_models/anthropic.py index 07634f6dcb..344f4f0b29 100644 --- a/libs/langchain/langchain/chat_models/anthropic.py +++ b/libs/langchain/langchain/chat_models/anthropic.py @@ -99,8 +99,9 @@ class ChatAnthropic(BaseChatModel, _AnthropicCommon): """Return type of chat model.""" return "anthropic-chat" - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether this model can be serialized by Langchain.""" return True def _convert_messages_to_prompt(self, messages: List[BaseMessage]) -> str: diff --git a/libs/langchain/langchain/chat_models/anyscale.py b/libs/langchain/langchain/chat_models/anyscale.py index 2ccae7ca75..3a57682042 100644 --- a/libs/langchain/langchain/chat_models/anyscale.py +++ b/libs/langchain/langchain/chat_models/anyscale.py @@ -4,7 +4,7 @@ from __future__ import annotations import logging import os import sys -from typing import TYPE_CHECKING, Optional, Set +from typing import TYPE_CHECKING, Dict, Optional, Set import requests @@ -50,7 +50,7 @@ class ChatAnyscale(ChatOpenAI): return "anyscale-chat" @property - def lc_secrets(self) -> dict[str, str]: + def lc_secrets(self) -> Dict[str, str]: return {"anyscale_api_key": "ANYSCALE_API_KEY"} anyscale_api_key: Optional[str] = None diff --git a/libs/langchain/langchain/chat_models/base.py b/libs/langchain/langchain/chat_models/base.py index ebe1ef2933..18278efd36 100644 --- a/libs/langchain/langchain/chat_models/base.py +++ b/libs/langchain/langchain/chat_models/base.py @@ -290,7 +290,7 @@ class BaseChatModel(BaseLanguageModel[BaseMessageChunk], ABC): return {**params, **kwargs} def _get_llm_string(self, stop: Optional[List[str]] = None, **kwargs: Any) -> str: - if self.lc_serializable: + if self.is_lc_serializable(): params = {**kwargs, **{"stop": stop}} param_string = str(sorted([(k, v) for k, v in params.items()])) llm_string = dumps(self) diff --git a/libs/langchain/langchain/chat_models/jinachat.py b/libs/langchain/langchain/chat_models/jinachat.py index d0e80bd288..51f5a0b60c 100644 --- a/libs/langchain/langchain/chat_models/jinachat.py +++ b/libs/langchain/langchain/chat_models/jinachat.py @@ -164,8 +164,9 @@ class JinaChat(BaseChatModel): def lc_secrets(self) -> Dict[str, str]: return {"jinachat_api_key": "JINACHAT_API_KEY"} - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether this model can be serialized by Langchain.""" return True client: Any #: :meta private: diff --git a/libs/langchain/langchain/chat_models/konko.py b/libs/langchain/langchain/chat_models/konko.py index 9735fb2ce5..ab46a4c2d9 100644 --- a/libs/langchain/langchain/chat_models/konko.py +++ b/libs/langchain/langchain/chat_models/konko.py @@ -55,8 +55,9 @@ class ChatKonko(ChatOpenAI): def lc_secrets(self) -> Dict[str, str]: return {"konko_api_key": "KONKO_API_KEY", "openai_api_key": "OPENAI_API_KEY"} - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether this model can be serialized by Langchain.""" return True client: Any = None #: :meta private: diff --git a/libs/langchain/langchain/chat_models/ollama.py b/libs/langchain/langchain/chat_models/ollama.py index a1fdcd0acc..b54d0063c7 100644 --- a/libs/langchain/langchain/chat_models/ollama.py +++ b/libs/langchain/langchain/chat_models/ollama.py @@ -47,8 +47,9 @@ class ChatOllama(BaseChatModel, _OllamaCommon): """Return type of chat model.""" return "ollama-chat" - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether this model can be serialized by Langchain.""" return True def _format_message_as_text(self, message: BaseMessage) -> str: diff --git a/libs/langchain/langchain/chat_models/openai.py b/libs/langchain/langchain/chat_models/openai.py index 664201b008..333c7fe37c 100644 --- a/libs/langchain/langchain/chat_models/openai.py +++ b/libs/langchain/langchain/chat_models/openai.py @@ -140,8 +140,9 @@ class ChatOpenAI(BaseChatModel): def lc_secrets(self) -> Dict[str, str]: return {"openai_api_key": "OPENAI_API_KEY"} - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether this model can be serialized by Langchain.""" return True client: Any = None #: :meta private: diff --git a/libs/langchain/langchain/llms/fireworks.py b/libs/langchain/langchain/llms/fireworks.py index 2b4b5f0ff9..96435fcfc5 100644 --- a/libs/langchain/langchain/llms/fireworks.py +++ b/libs/langchain/langchain/llms/fireworks.py @@ -51,8 +51,8 @@ class BaseFireworks(BaseLLM): def lc_secrets(self) -> Dict[str, str]: return {"fireworks_api_key": "FIREWORKS_API_KEY"} - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True def __new__(cls, **data: Any) -> Any: diff --git a/libs/langchain/langchain/llms/openai.py b/libs/langchain/langchain/llms/openai.py index 2ec199149c..462dfe4a6d 100644 --- a/libs/langchain/langchain/llms/openai.py +++ b/libs/langchain/langchain/llms/openai.py @@ -138,8 +138,8 @@ class BaseOpenAI(BaseLLM): def lc_secrets(self) -> Dict[str, str]: return {"openai_api_key": "OPENAI_API_KEY"} - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True client: Any = None #: :meta private: diff --git a/libs/langchain/langchain/llms/replicate.py b/libs/langchain/langchain/llms/replicate.py index 7a146070ec..e94cc1fad7 100644 --- a/libs/langchain/langchain/llms/replicate.py +++ b/libs/langchain/langchain/llms/replicate.py @@ -65,8 +65,8 @@ class Replicate(LLM): def lc_secrets(self) -> Dict[str, str]: return {"replicate_api_token": "REPLICATE_API_TOKEN"} - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True @root_validator(pre=True) diff --git a/libs/langchain/langchain/llms/tongyi.py b/libs/langchain/langchain/llms/tongyi.py index 80447a6191..8b63b1f352 100644 --- a/libs/langchain/langchain/llms/tongyi.py +++ b/libs/langchain/langchain/llms/tongyi.py @@ -102,8 +102,8 @@ class Tongyi(LLM): def lc_secrets(self) -> Dict[str, str]: return {"dashscope_api_key": "DASHSCOPE_API_KEY"} - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True client: Any #: :meta private: diff --git a/libs/langchain/langchain/load/serializable.py b/libs/langchain/langchain/load/serializable.py index 46fdf2878b..622623f1e3 100644 --- a/libs/langchain/langchain/load/serializable.py +++ b/libs/langchain/langchain/load/serializable.py @@ -34,20 +34,19 @@ class SerializedNotImplemented(BaseSerialized): class Serializable(BaseModel, ABC): """Serializable base class.""" - @property - def lc_serializable(self) -> bool: - """ - Return whether or not the class is serializable. - """ + @classmethod + def is_lc_serializable(cls) -> bool: + """Is this class serializable?""" return False - @property - def lc_namespace(self) -> List[str]: - """ - Return the namespace of the langchain object. - eg. ["langchain", "llms", "openai"] + @classmethod + def get_lc_namespace(cls) -> List[str]: + """Get the namespace of the langchain object. + + For example, if the class is `langchain.llms.openai.OpenAI`, then the + namespace is ["langchain", "llms", "openai"] """ - return self.__class__.__module__.split(".") + return cls.__module__.split(".") @property def lc_secrets(self) -> Dict[str, str]: @@ -76,7 +75,7 @@ class Serializable(BaseModel, ABC): self._lc_kwargs = kwargs def to_json(self) -> Union[SerializedConstructor, SerializedNotImplemented]: - if not self.lc_serializable: + if not self.is_lc_serializable(): return self.to_json_not_implemented() secrets = dict() @@ -93,6 +92,20 @@ class Serializable(BaseModel, ABC): if cls is Serializable: break + if cls: + deprecated_attributes = [ + "lc_namespace", + "lc_serializable", + ] + + for attr in deprecated_attributes: + if hasattr(cls, attr): + raise ValueError( + f"Class {self.__class__} has a deprecated " + f"attribute {attr}. Please use the corresponding " + f"classmethod instead." + ) + # Get a reference to self bound to each class in the MRO this = cast(Serializable, self if cls is None else super(cls, self)) @@ -109,7 +122,7 @@ class Serializable(BaseModel, ABC): return { "lc": 1, "type": "constructor", - "id": [*self.lc_namespace, self.__class__.__name__], + "id": [*self.get_lc_namespace(), self.__class__.__name__], "kwargs": lc_kwargs if not secrets else _replace_secrets(lc_kwargs, secrets), diff --git a/libs/langchain/langchain/output_parsers/combining.py b/libs/langchain/langchain/output_parsers/combining.py index 3ca3cb9622..34099dcefa 100644 --- a/libs/langchain/langchain/output_parsers/combining.py +++ b/libs/langchain/langchain/output_parsers/combining.py @@ -9,8 +9,8 @@ from langchain.schema import BaseOutputParser class CombiningOutputParser(BaseOutputParser): """Combine multiple output parsers into one.""" - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True parsers: List[BaseOutputParser] diff --git a/libs/langchain/langchain/output_parsers/fix.py b/libs/langchain/langchain/output_parsers/fix.py index af5e33b42f..84b4b762f3 100644 --- a/libs/langchain/langchain/output_parsers/fix.py +++ b/libs/langchain/langchain/output_parsers/fix.py @@ -13,8 +13,8 @@ T = TypeVar("T") class OutputFixingParser(BaseOutputParser[T]): """Wraps a parser and tries to fix parsing errors.""" - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True parser: BaseOutputParser[T] diff --git a/libs/langchain/langchain/output_parsers/list.py b/libs/langchain/langchain/output_parsers/list.py index 6680cb908a..3ee9604366 100644 --- a/libs/langchain/langchain/output_parsers/list.py +++ b/libs/langchain/langchain/output_parsers/list.py @@ -22,8 +22,8 @@ class ListOutputParser(BaseOutputParser[List[str]]): class CommaSeparatedListOutputParser(ListOutputParser): """Parse the output of an LLM call to a comma-separated list.""" - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True def get_format_instructions(self) -> str: diff --git a/libs/langchain/langchain/output_parsers/regex.py b/libs/langchain/langchain/output_parsers/regex.py index cdddb08399..5166c09c39 100644 --- a/libs/langchain/langchain/output_parsers/regex.py +++ b/libs/langchain/langchain/output_parsers/regex.py @@ -9,8 +9,8 @@ from langchain.schema import BaseOutputParser class RegexParser(BaseOutputParser): """Parse the output of an LLM call using a regex.""" - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True regex: str diff --git a/libs/langchain/langchain/prompts/chat.py b/libs/langchain/langchain/prompts/chat.py index 5b177bc124..6e044473d0 100644 --- a/libs/langchain/langchain/prompts/chat.py +++ b/libs/langchain/langchain/prompts/chat.py @@ -39,13 +39,9 @@ from langchain.schema.messages import ( class BaseMessagePromptTemplate(Serializable, ABC): """Base class for message prompt templates.""" - @property - def lc_serializable(self) -> bool: - """Whether this object should be serialized. - - Returns: - Whether this object should be serialized. - """ + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether or not the class is serializable.""" return True @abstractmethod diff --git a/libs/langchain/langchain/prompts/few_shot.py b/libs/langchain/langchain/prompts/few_shot.py index 72ba8c13fd..bf9c4421b0 100644 --- a/libs/langchain/langchain/prompts/few_shot.py +++ b/libs/langchain/langchain/prompts/few_shot.py @@ -71,13 +71,9 @@ class _FewShotPromptTemplateMixin(BaseModel): class FewShotPromptTemplate(_FewShotPromptTemplateMixin, StringPromptTemplate): """Prompt template that contains few shot examples.""" - @property - def lc_serializable(self) -> bool: - """Return whether the prompt template is lc_serializable. - - Returns: - Boolean indicating whether the prompt template is lc_serializable. - """ + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether or not the class is serializable.""" return False validate_template: bool = True @@ -278,13 +274,9 @@ class FewShotChatMessagePromptTemplate( chain.invoke({"input": "What's 3+3?"}) """ - @property - def lc_serializable(self) -> bool: - """Return whether the prompt template is lc_serializable. - - Returns: - Boolean indicating whether the prompt template is lc_serializable. - """ + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether or not the class is serializable.""" return False input_variables: List[str] = Field(default_factory=list) diff --git a/libs/langchain/langchain/schema/agent.py b/libs/langchain/langchain/schema/agent.py index deb292ba3c..a6d269b7e0 100644 --- a/libs/langchain/langchain/schema/agent.py +++ b/libs/langchain/langchain/schema/agent.py @@ -27,11 +27,9 @@ class AgentAction(Serializable): ): super().__init__(tool=tool, tool_input=tool_input, log=log, **kwargs) - @property - def lc_serializable(self) -> bool: - """ - Return whether or not the class is serializable. - """ + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether or not the class is serializable.""" return True @@ -62,9 +60,7 @@ class AgentFinish(Serializable): def __init__(self, return_values: dict, log: str, **kwargs: Any): super().__init__(return_values=return_values, log=log, **kwargs) - @property - def lc_serializable(self) -> bool: - """ - Return whether or not the class is serializable. - """ + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether or not the class is serializable.""" return True diff --git a/libs/langchain/langchain/schema/document.py b/libs/langchain/langchain/schema/document.py index ccee67ca2a..d0a4f666f5 100644 --- a/libs/langchain/langchain/schema/document.py +++ b/libs/langchain/langchain/schema/document.py @@ -17,9 +17,9 @@ class Document(Serializable): documents, etc.). """ - @property - def lc_serializable(self) -> bool: - """Return whether or not the class is serializable.""" + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether this class is serializable.""" return True diff --git a/libs/langchain/langchain/schema/messages.py b/libs/langchain/langchain/schema/messages.py index e0134da0d8..ee0039f0e9 100644 --- a/libs/langchain/langchain/schema/messages.py +++ b/libs/langchain/langchain/schema/messages.py @@ -74,9 +74,9 @@ class BaseMessage(Serializable): def type(self) -> str: """Type of the Message, used for serialization.""" - @property - def lc_serializable(self) -> bool: - """Whether this class is LangChain serializable.""" + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether this class is serializable.""" return True def __add__(self, other: Any) -> ChatPromptTemplate: diff --git a/libs/langchain/langchain/schema/output.py b/libs/langchain/langchain/schema/output.py index 589573ee58..a612f4bd28 100644 --- a/libs/langchain/langchain/schema/output.py +++ b/libs/langchain/langchain/schema/output.py @@ -21,9 +21,9 @@ class Generation(Serializable): """ # TODO: add log probs as separate attribute - @property - def lc_serializable(self) -> bool: - """Whether this class is LangChain serializable.""" + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether this class is serializable.""" return True diff --git a/libs/langchain/langchain/schema/output_parser.py b/libs/langchain/langchain/schema/output_parser.py index 9e7a8083f2..c0680cad17 100644 --- a/libs/langchain/langchain/schema/output_parser.py +++ b/libs/langchain/langchain/schema/output_parser.py @@ -304,9 +304,9 @@ class BaseTransformOutputParser(BaseOutputParser[T]): class StrOutputParser(BaseTransformOutputParser[str]): """OutputParser that parses LLMResult into the top likely string.""" - @property - def lc_serializable(self) -> bool: - """Whether the class LangChain serializable.""" + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether this class is serializable.""" return True @property diff --git a/libs/langchain/langchain/schema/prompt.py b/libs/langchain/langchain/schema/prompt.py index 951954c5f2..8410eb73e6 100644 --- a/libs/langchain/langchain/schema/prompt.py +++ b/libs/langchain/langchain/schema/prompt.py @@ -14,11 +14,9 @@ class PromptValue(Serializable, ABC): ChatModel inputs. """ - @property - def lc_serializable(self) -> bool: - """ - Return whether or not the class is serializable. - """ + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether this class is serializable.""" return True @abstractmethod diff --git a/libs/langchain/langchain/schema/prompt_template.py b/libs/langchain/langchain/schema/prompt_template.py index 0caaed131f..42676827e4 100644 --- a/libs/langchain/langchain/schema/prompt_template.py +++ b/libs/langchain/langchain/schema/prompt_template.py @@ -26,8 +26,9 @@ class BasePromptTemplate(Serializable, Runnable[Dict, PromptValue], ABC): default_factory=dict ) - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether this class is serializable.""" return True class Config: diff --git a/libs/langchain/langchain/schema/runnable/base.py b/libs/langchain/langchain/schema/runnable/base.py index e049ed73fa..b981affa0b 100644 --- a/libs/langchain/langchain/schema/runnable/base.py +++ b/libs/langchain/langchain/schema/runnable/base.py @@ -834,15 +834,15 @@ class RunnableBranch(Serializable, Runnable[Input, Output]): class Config: arbitrary_types_allowed = True - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: """RunnableBranch is serializable if all its branches are serializable.""" return True - @property - def lc_namespace(self) -> List[str]: + @classmethod + def get_lc_namespace(cls) -> List[str]: """The namespace of a RunnableBranch is the namespace of its default branch.""" - return self.__class__.__module__.split(".")[:-1] + return cls.__module__.split(".")[:-1] def invoke(self, input: Input, config: Optional[RunnableConfig] = None) -> Output: """First evaluates the condition, then delegate to true or false branch.""" @@ -946,13 +946,13 @@ class RunnableWithFallbacks(Serializable, Runnable[Input, Output]): class Config: arbitrary_types_allowed = True - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True - @property - def lc_namespace(self) -> List[str]: - return self.__class__.__module__.split(".")[:-1] + @classmethod + def get_lc_namespace(cls) -> List[str]: + return cls.__module__.split(".")[:-1] @property def runnables(self) -> Iterator[Runnable[Input, Output]]: @@ -1184,13 +1184,13 @@ class RunnableSequence(Serializable, Runnable[Input, Output]): def steps(self) -> List[Runnable[Any, Any]]: return [self.first] + self.middle + [self.last] - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True - @property - def lc_namespace(self) -> List[str]: - return self.__class__.__module__.split(".")[:-1] + @classmethod + def get_lc_namespace(cls) -> List[str]: + return cls.__module__.split(".")[:-1] class Config: arbitrary_types_allowed = True @@ -1674,13 +1674,13 @@ class RunnableMap(Serializable, Runnable[Input, Dict[str, Any]]): ) -> None: super().__init__(steps={key: coerce_to_runnable(r) for key, r in steps.items()}) - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True - @property - def lc_namespace(self) -> List[str]: - return self.__class__.__module__.split(".")[:-1] + @classmethod + def get_lc_namespace(cls) -> List[str]: + return cls.__module__.split(".")[:-1] class Config: arbitrary_types_allowed = True @@ -2061,13 +2061,13 @@ class RunnableEach(Serializable, Runnable[List[Input], List[Output]]): class Config: arbitrary_types_allowed = True - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True - @property - def lc_namespace(self) -> List[str]: - return self.__class__.__module__.split(".")[:-1] + @classmethod + def get_lc_namespace(cls) -> List[str]: + return cls.__module__.split(".")[:-1] def bind(self, **kwargs: Any) -> RunnableEach[Input, Output]: return RunnableEach(bound=self.bound.bind(**kwargs)) @@ -2117,13 +2117,13 @@ class RunnableBinding(Serializable, Runnable[Input, Output]): class Config: arbitrary_types_allowed = True - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True - @property - def lc_namespace(self) -> List[str]: - return self.__class__.__module__.split(".")[:-1] + @classmethod + def get_lc_namespace(cls) -> List[str]: + return cls.__module__.split(".")[:-1] def _merge_config(self, config: Optional[RunnableConfig]) -> RunnableConfig: copy = cast(RunnableConfig, dict(self.config)) diff --git a/libs/langchain/langchain/schema/runnable/passthrough.py b/libs/langchain/langchain/schema/runnable/passthrough.py index d5d7c152c1..d1ad275e4e 100644 --- a/libs/langchain/langchain/schema/runnable/passthrough.py +++ b/libs/langchain/langchain/schema/runnable/passthrough.py @@ -20,13 +20,13 @@ class RunnablePassthrough(Serializable, Runnable[Input, Input]): A runnable that passes through the input. """ - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True - @property - def lc_namespace(self) -> List[str]: - return self.__class__.__module__.split(".")[:-1] + @classmethod + def get_lc_namespace(cls) -> List[str]: + return cls.__module__.split(".")[:-1] def invoke(self, input: Input, config: Optional[RunnableConfig] = None) -> Input: return self._call_with_config(identity, input, config) diff --git a/libs/langchain/langchain/schema/runnable/router.py b/libs/langchain/langchain/schema/runnable/router.py index 4f723d7ed3..799e5f22d6 100644 --- a/libs/langchain/langchain/schema/runnable/router.py +++ b/libs/langchain/langchain/schema/runnable/router.py @@ -66,13 +66,14 @@ class RouterRunnable( class Config: arbitrary_types_allowed = True - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether this class is serializable.""" return True - @property - def lc_namespace(self) -> List[str]: - return self.__class__.__module__.split(".")[:-1] + @classmethod + def get_lc_namespace(cls) -> List[str]: + return cls.__module__.split(".")[:-1] def __or__( self, diff --git a/libs/langchain/tests/unit_tests/load/test_dump.py b/libs/langchain/tests/unit_tests/load/test_dump.py index 332f6fd269..e45115ed0f 100644 --- a/libs/langchain/tests/unit_tests/load/test_dump.py +++ b/libs/langchain/tests/unit_tests/load/test_dump.py @@ -19,8 +19,8 @@ class Person(Serializable): you_can_see_me: str = "hello" - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: return True @property diff --git a/libs/langchain/tests/unit_tests/schema/runnable/test_runnable.py b/libs/langchain/tests/unit_tests/schema/runnable/test_runnable.py index 7fed5d6648..28f0045a2d 100644 --- a/libs/langchain/tests/unit_tests/schema/runnable/test_runnable.py +++ b/libs/langchain/tests/unit_tests/schema/runnable/test_runnable.py @@ -1694,8 +1694,9 @@ async def test_llm_with_fallbacks( class FakeSplitIntoListParser(BaseOutputParser[List[str]]): """Parse the output of an LLM call to a comma-separated list.""" - @property - def lc_serializable(self) -> bool: + @classmethod + def is_lc_serializable(cls) -> bool: + """Return whether or not the class is serializable.""" return True def get_format_instructions(self) -> str: