From db36a0ee99c068528a9245bebc21fda8a4e907f0 Mon Sep 17 00:00:00 2001 From: David Duong Date: Tue, 3 Oct 2023 00:46:48 +0200 Subject: [PATCH] Make Google PaLM classes serialisable (#11121) Similarly to Vertex classes, PaLM classes weren't marked as serialisable. Should be working fine with LangSmith. --------- Co-authored-by: Erick Friis --- libs/langchain/langchain/chat_models/google_palm.py | 8 ++++++++ libs/langchain/langchain/llms/google_palm.py | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/libs/langchain/langchain/chat_models/google_palm.py b/libs/langchain/langchain/chat_models/google_palm.py index cc7c288f89..5b8a62edcd 100644 --- a/libs/langchain/langchain/chat_models/google_palm.py +++ b/libs/langchain/langchain/chat_models/google_palm.py @@ -248,6 +248,14 @@ class ChatGooglePalm(BaseChatModel, BaseModel): """Number of chat completions to generate for each prompt. Note that the API may not return the full n completions if duplicates are generated.""" + @property + def lc_secrets(self) -> Dict[str, str]: + return {"google_api_key": "GOOGLE_API_KEY"} + + @classmethod + def is_lc_serializable(self) -> bool: + return True + @root_validator() def validate_environment(cls, values: Dict) -> Dict: """Validate api key, python package exists, temperature, top_p, and top_k.""" diff --git a/libs/langchain/langchain/llms/google_palm.py b/libs/langchain/langchain/llms/google_palm.py index 1a0a409979..b15f383d1a 100644 --- a/libs/langchain/langchain/llms/google_palm.py +++ b/libs/langchain/langchain/llms/google_palm.py @@ -95,6 +95,14 @@ class GooglePalm(BaseLLM, BaseModel): """Number of chat completions to generate for each prompt. Note that the API may not return the full n completions if duplicates are generated.""" + @property + def lc_secrets(self) -> Dict[str, str]: + return {"google_api_key": "GOOGLE_API_KEY"} + + @classmethod + def is_lc_serializable(self) -> bool: + return True + @root_validator() def validate_environment(cls, values: Dict) -> Dict: """Validate api key, python package exists."""