diff --git a/libs/langchain/langchain/agents/openai_assistant/base.py b/libs/langchain/langchain/agents/openai_assistant/base.py index 7939542858909..fa827adca5f0f 100644 --- a/libs/langchain/langchain/agents/openai_assistant/base.py +++ b/libs/langchain/langchain/agents/openai_assistant/base.py @@ -28,6 +28,10 @@ class OpenAIAssistantFinish(AgentFinish): run_id: str thread_id: str + @classmethod + def is_lc_serializable(cls) -> bool: + return False + class OpenAIAssistantAction(AgentAction): """AgentAction with info needed to submit custom tool output to existing run.""" @@ -36,6 +40,10 @@ class OpenAIAssistantAction(AgentAction): run_id: str thread_id: str + @classmethod + def is_lc_serializable(cls) -> bool: + return False + def _get_openai_client() -> openai.OpenAI: try: diff --git a/libs/langchain/langchain/agents/schema.py b/libs/langchain/langchain/agents/schema.py index 6c16cad9e6dd6..e0c00fb95e8a0 100644 --- a/libs/langchain/langchain/agents/schema.py +++ b/libs/langchain/langchain/agents/schema.py @@ -7,6 +7,10 @@ class AgentScratchPadChatPromptTemplate(ChatPromptTemplate): """Chat prompt template for the agent scratchpad.""" + @classmethod + def is_lc_serializable(cls) -> bool: + return False + def _construct_agent_scratchpad( self, intermediate_steps: List[Tuple[AgentAction, str]] ) -> str: diff --git a/libs/langchain/langchain/chains/api/openapi/requests_chain.py b/libs/langchain/langchain/chains/api/openapi/requests_chain.py index 50179cc90294c..cca19165ee2e3 100644 --- a/libs/langchain/langchain/chains/api/openapi/requests_chain.py +++ b/libs/langchain/langchain/chains/api/openapi/requests_chain.py @@ -40,6 +40,10 @@ def _type(self) -> str: class APIRequesterChain(LLMChain): """Get the request parser.""" + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @classmethod def from_llm_and_typescript( cls, diff --git a/libs/langchain/langchain/chains/api/openapi/response_chain.py b/libs/langchain/langchain/chains/api/openapi/response_chain.py index 1c6156091f29e..06e7686b4a379 100644 --- a/libs/langchain/langchain/chains/api/openapi/response_chain.py +++ b/libs/langchain/langchain/chains/api/openapi/response_chain.py @@ -40,6 +40,10 @@ def _type(self) -> str: class APIResponderChain(LLMChain): """Get the response parser.""" + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @classmethod def from_llm( cls, llm: BaseLanguageModel, verbose: bool = True, **kwargs: Any diff --git a/libs/langchain/langchain/chains/conversation/base.py b/libs/langchain/langchain/chains/conversation/base.py index d05e7920b5ef6..f0c42217343de 100644 --- a/libs/langchain/langchain/chains/conversation/base.py +++ b/libs/langchain/langchain/chains/conversation/base.py @@ -36,6 +36,10 @@ class Config: extra = Extra.forbid arbitrary_types_allowed = True + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @property def input_keys(self) -> List[str]: """Use this since so some prompt vars come from history.""" diff --git a/libs/langchain/langchain/chains/flare/base.py b/libs/langchain/langchain/chains/flare/base.py index 638212d54efac..de673f6cb8647 100644 --- a/libs/langchain/langchain/chains/flare/base.py +++ b/libs/langchain/langchain/chains/flare/base.py @@ -29,6 +29,10 @@ class _ResponseChain(LLMChain): prompt: BasePromptTemplate = PROMPT + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @property def input_keys(self) -> List[str]: return self.prompt.input_variables @@ -77,6 +81,10 @@ class QuestionGeneratorChain(LLMChain): prompt: BasePromptTemplate = QUESTION_GENERATOR_PROMPT """Prompt template for the chain.""" + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @property def input_keys(self) -> List[str]: """Input keys for the chain.""" diff --git a/libs/langchain/langchain/chat_models/anyscale.py b/libs/langchain/langchain/chat_models/anyscale.py index 27efc4a1abfb1..ff579d27f5f70 100644 --- a/libs/langchain/langchain/chat_models/anyscale.py +++ b/libs/langchain/langchain/chat_models/anyscale.py @@ -57,6 +57,10 @@ def _llm_type(self) -> str: def lc_secrets(self) -> Dict[str, str]: return {"anyscale_api_key": "ANYSCALE_API_KEY"} + @classmethod + def is_lc_serializable(cls) -> bool: + return False + anyscale_api_key: SecretStr """AnyScale Endpoints API keys.""" model_name: str = Field(default=DEFAULT_MODEL, alias="model") diff --git a/libs/langchain/langchain/chat_models/everlyai.py b/libs/langchain/langchain/chat_models/everlyai.py index 95bddaba5b06d..046f00f6e77e1 100644 --- a/libs/langchain/langchain/chat_models/everlyai.py +++ b/libs/langchain/langchain/chat_models/everlyai.py @@ -51,6 +51,10 @@ def _llm_type(self) -> str: def lc_secrets(self) -> Dict[str, str]: return {"everlyai_api_key": "EVERLYAI_API_KEY"} + @classmethod + def is_lc_serializable(cls) -> bool: + return False + everlyai_api_key: Optional[str] = None """EverlyAI Endpoints API keys.""" model_name: str = Field(default=DEFAULT_MODEL, alias="model") diff --git a/libs/langchain/langchain/chat_models/jinachat.py b/libs/langchain/langchain/chat_models/jinachat.py index bdb77e25b20a0..abaf57b5ff31e 100644 --- a/libs/langchain/langchain/chat_models/jinachat.py +++ b/libs/langchain/langchain/chat_models/jinachat.py @@ -165,7 +165,7 @@ def lc_secrets(self) -> Dict[str, str]: @classmethod def is_lc_serializable(cls) -> bool: """Return whether this model can be serialized by Langchain.""" - return True + return False client: Any #: :meta private: temperature: float = 0.7 diff --git a/libs/langchain/langchain/chat_models/konko.py b/libs/langchain/langchain/chat_models/konko.py index eaafb108105f7..8065c3cb10756 100644 --- a/libs/langchain/langchain/chat_models/konko.py +++ b/libs/langchain/langchain/chat_models/konko.py @@ -57,7 +57,7 @@ def lc_secrets(self) -> Dict[str, str]: @classmethod def is_lc_serializable(cls) -> bool: """Return whether this model can be serialized by Langchain.""" - return True + return False client: Any = None #: :meta private: model: str = Field(default=DEFAULT_MODEL, alias="model") diff --git a/libs/langchain/langchain/chat_models/ollama.py b/libs/langchain/langchain/chat_models/ollama.py index b356733566d16..819f657fb9678 100644 --- a/libs/langchain/langchain/chat_models/ollama.py +++ b/libs/langchain/langchain/chat_models/ollama.py @@ -50,7 +50,7 @@ def _llm_type(self) -> str: @classmethod def is_lc_serializable(cls) -> bool: """Return whether this model can be serialized by Langchain.""" - return True + return False def _format_message_as_text(self, message: BaseMessage) -> str: if isinstance(message, ChatMessage): diff --git a/libs/langchain/langchain/chat_models/promptlayer_openai.py b/libs/langchain/langchain/chat_models/promptlayer_openai.py index e7146b6ecaa30..bab7a1ffdb04f 100644 --- a/libs/langchain/langchain/chat_models/promptlayer_openai.py +++ b/libs/langchain/langchain/chat_models/promptlayer_openai.py @@ -39,6 +39,10 @@ class PromptLayerChatOpenAI(ChatOpenAI): pl_tags: Optional[List[str]] return_pl_id: Optional[bool] = False + @classmethod + def is_lc_serializable(cls) -> bool: + return False + def _generate( self, messages: List[BaseMessage], diff --git a/libs/langchain/langchain/chat_models/volcengine_maas.py b/libs/langchain/langchain/chat_models/volcengine_maas.py index 5ce8378d94f36..2af4754179384 100644 --- a/libs/langchain/langchain/chat_models/volcengine_maas.py +++ b/libs/langchain/langchain/chat_models/volcengine_maas.py @@ -76,7 +76,7 @@ def _llm_type(self) -> str: @classmethod def is_lc_serializable(cls) -> bool: """Return whether this model can be serialized by Langchain.""" - return True + return False @property def _identifying_params(self) -> Dict[str, Any]: diff --git a/libs/langchain/langchain/document_transformers/embeddings_redundant_filter.py b/libs/langchain/langchain/document_transformers/embeddings_redundant_filter.py index d7772a3092ded..276ac2061f700 100644 --- a/libs/langchain/langchain/document_transformers/embeddings_redundant_filter.py +++ b/libs/langchain/langchain/document_transformers/embeddings_redundant_filter.py @@ -15,6 +15,10 @@ class _DocumentWithState(Document): state: dict = Field(default_factory=dict) """State associated with the document.""" + @classmethod + def is_lc_serializable(cls) -> bool: + return False + def to_document(self) -> Document: """Convert the DocumentWithState to a Document.""" return Document(page_content=self.page_content, metadata=self.metadata) diff --git a/libs/langchain/langchain/evaluation/comparison/eval_chain.py b/libs/langchain/langchain/evaluation/comparison/eval_chain.py index 65f8fc939a8f8..aaf97b22178fc 100644 --- a/libs/langchain/langchain/evaluation/comparison/eval_chain.py +++ b/libs/langchain/langchain/evaluation/comparison/eval_chain.py @@ -188,6 +188,10 @@ class PairwiseStringEvalChain(PairwiseStringEvaluator, LLMEvalChain, LLMChain): default_factory=PairwiseStringResultOutputParser ) + @classmethod + def is_lc_serializable(cls) -> bool: + return False + class Config: """Configuration for the PairwiseStringEvalChain.""" diff --git a/libs/langchain/langchain/evaluation/criteria/eval_chain.py b/libs/langchain/langchain/evaluation/criteria/eval_chain.py index ac3bb1211c8b0..ab167477c454f 100644 --- a/libs/langchain/langchain/evaluation/criteria/eval_chain.py +++ b/libs/langchain/langchain/evaluation/criteria/eval_chain.py @@ -232,6 +232,10 @@ class CriteriaEvalChain(StringEvaluator, LLMEvalChain, LLMChain): """The name of the criterion being evaluated.""" output_key: str = "results" #: :meta private: + @classmethod + def is_lc_serializable(cls) -> bool: + return False + class Config: """Configuration for the QAEvalChain.""" @@ -508,6 +512,10 @@ async def _aevaluate_strings( class LabeledCriteriaEvalChain(CriteriaEvalChain): """Criteria evaluation chain that requires references.""" + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @property def requires_reference(self) -> bool: """Whether the evaluation requires a reference text.""" diff --git a/libs/langchain/langchain/evaluation/qa/eval_chain.py b/libs/langchain/langchain/evaluation/qa/eval_chain.py index ae63aa343f8c1..9a465d025547f 100644 --- a/libs/langchain/langchain/evaluation/qa/eval_chain.py +++ b/libs/langchain/langchain/evaluation/qa/eval_chain.py @@ -77,6 +77,10 @@ class Config: extra = Extra.ignore + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @property def evaluation_name(self) -> str: return "correctness" @@ -204,6 +208,10 @@ async def _aevaluate_strings( class ContextQAEvalChain(LLMChain, StringEvaluator, LLMEvalChain): """LLM Chain for evaluating QA w/o GT based on context""" + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @property def requires_reference(self) -> bool: """Whether the chain requires a reference string.""" @@ -328,6 +336,10 @@ async def _aevaluate_strings( class CotQAEvalChain(ContextQAEvalChain): """LLM Chain for evaluating QA using chain of thought reasoning.""" + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @property def evaluation_name(self) -> str: return "COT Contextual Accuracy" diff --git a/libs/langchain/langchain/evaluation/qa/generate_chain.py b/libs/langchain/langchain/evaluation/qa/generate_chain.py index 46854fae00642..219978f739d02 100644 --- a/libs/langchain/langchain/evaluation/qa/generate_chain.py +++ b/libs/langchain/langchain/evaluation/qa/generate_chain.py @@ -22,6 +22,10 @@ class QAGenerateChain(LLMChain): output_parser: BaseLLMOutputParser = Field(default=_QA_OUTPUT_PARSER) output_key: str = "qa_pairs" + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @classmethod def from_llm(cls, llm: BaseLanguageModel, **kwargs: Any) -> QAGenerateChain: """Load QA Generate Chain from LLM.""" diff --git a/libs/langchain/langchain/evaluation/scoring/eval_chain.py b/libs/langchain/langchain/evaluation/scoring/eval_chain.py index 3f7449bb0dc28..dab0d4842f6bb 100644 --- a/libs/langchain/langchain/evaluation/scoring/eval_chain.py +++ b/libs/langchain/langchain/evaluation/scoring/eval_chain.py @@ -185,6 +185,10 @@ class Config: extra = Extra.ignore + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @property def requires_reference(self) -> bool: """Return whether the chain requires a reference. diff --git a/libs/langchain/langchain/indexes/_api.py b/libs/langchain/langchain/indexes/_api.py index 5637a12511b3e..29bf6dfb5ea7e 100644 --- a/libs/langchain/langchain/indexes/_api.py +++ b/libs/langchain/langchain/indexes/_api.py @@ -58,6 +58,10 @@ class _HashedDocument(Document): metadata_hash: str """The hash of the document metadata.""" + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @root_validator(pre=True) def calculate_hashes(cls, values: Dict[str, Any]) -> Dict[str, Any]: """Root validator to calculate content and metadata hash.""" diff --git a/libs/langchain/langchain/llms/anyscale.py b/libs/langchain/langchain/llms/anyscale.py index e2f26463ecd95..a58bbb183df1c 100644 --- a/libs/langchain/langchain/llms/anyscale.py +++ b/libs/langchain/langchain/llms/anyscale.py @@ -90,6 +90,10 @@ def send_query(llm, text): prefix_messages: List = Field(default_factory=list) + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @root_validator() def validate_environment(cls, values: Dict) -> Dict: """Validate that api key and python package exists in environment.""" diff --git a/libs/langchain/langchain/llms/openlm.py b/libs/langchain/langchain/llms/openlm.py index fcbf3af584209..13231e85641da 100644 --- a/libs/langchain/langchain/llms/openlm.py +++ b/libs/langchain/langchain/llms/openlm.py @@ -8,6 +8,10 @@ class OpenLM(BaseOpenAI): """OpenLM models.""" + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @property def _invocation_params(self) -> Dict[str, Any]: return {**{"model": self.model_name}, **super()._invocation_params} diff --git a/libs/langchain/langchain/llms/promptlayer_openai.py b/libs/langchain/langchain/llms/promptlayer_openai.py index b8037cdbfbe7d..025347aabe13d 100644 --- a/libs/langchain/langchain/llms/promptlayer_openai.py +++ b/libs/langchain/langchain/llms/promptlayer_openai.py @@ -37,6 +37,10 @@ class PromptLayerOpenAI(OpenAI): pl_tags: Optional[List[str]] return_pl_id: Optional[bool] = False + @classmethod + def is_lc_serializable(cls) -> bool: + return False + def _generate( self, prompts: List[str], diff --git a/libs/langchain/langchain/llms/tongyi.py b/libs/langchain/langchain/llms/tongyi.py index 1ecd238cd745e..3606e6289f8aa 100644 --- a/libs/langchain/langchain/llms/tongyi.py +++ b/libs/langchain/langchain/llms/tongyi.py @@ -106,7 +106,7 @@ def lc_secrets(self) -> Dict[str, str]: @classmethod def is_lc_serializable(cls) -> bool: - return True + return False client: Any #: :meta private: model_name: str = "qwen-plus-v1" diff --git a/libs/langchain/langchain/llms/vllm.py b/libs/langchain/langchain/llms/vllm.py index 4ccb5a743bee9..0b86ac6947b7a 100644 --- a/libs/langchain/langchain/llms/vllm.py +++ b/libs/langchain/langchain/llms/vllm.py @@ -147,6 +147,10 @@ def _llm_type(self) -> str: class VLLMOpenAI(BaseOpenAI): """vLLM OpenAI-compatible API client""" + @classmethod + def is_lc_serializable(cls) -> bool: + return False + @property def _invocation_params(self) -> Dict[str, Any]: """Get the parameters used to invoke the model.""" diff --git a/libs/langchain/langchain/llms/watsonxllm.py b/libs/langchain/langchain/llms/watsonxllm.py index 40005437816bf..a316da2fb544c 100644 --- a/libs/langchain/langchain/llms/watsonxllm.py +++ b/libs/langchain/langchain/llms/watsonxllm.py @@ -97,7 +97,7 @@ class Config: @classmethod def is_lc_serializable(cls) -> bool: - return True + return False @property def lc_secrets(self) -> Dict[str, str]: