Skip to content

The agent engineering platform.

Make Google PaLM classes serialisable (#11121)

David Duongdb36a0ee99c0
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."""