From 51c4393298801b75f98cf8a060376237a734eac1 Mon Sep 17 00:00:00 2001 From: Rajendra Kadam Date: Wed, 25 Sep 2024 19:32:14 +0530 Subject: [PATCH] community[patch]: Fix validation error in SettingsConfigDict across multiple Langchain modules (#26852) - **Description:** This pull request addresses the validation error in `SettingsConfigDict` due to extra fields in the `.env` file. The issue is prevalent across multiple Langchain modules. This fix ensures that extra fields in the `.env` file are ignored, preventing validation errors. **Changes include:** - Applied fixes to modules using `SettingsConfigDict`. - **Issue:** NA, similar https://github.com/langchain-ai/langchain/issues/26850 - **Dependencies:** NA --- .../langchain_community/document_loaders/onenote.py | 1 + .../langchain_community/vectorstores/apache_doris.py | 5 ++++- .../community/langchain_community/vectorstores/clickhouse.py | 5 ++++- libs/community/langchain_community/vectorstores/kinetica.py | 5 ++++- .../langchain_community/vectorstores/manticore_search.py | 5 ++++- libs/community/langchain_community/vectorstores/myscale.py | 5 ++++- libs/community/langchain_community/vectorstores/starrocks.py | 5 ++++- 7 files changed, 25 insertions(+), 6 deletions(-) diff --git a/libs/community/langchain_community/document_loaders/onenote.py b/libs/community/langchain_community/document_loaders/onenote.py index c58640e0846e8..e19b57044d186 100644 --- a/libs/community/langchain_community/document_loaders/onenote.py +++ b/libs/community/langchain_community/document_loaders/onenote.py @@ -26,6 +26,7 @@ class _OneNoteGraphSettings(BaseSettings): populate_by_name=True, env_file=".env", env_prefix="MS_GRAPH_", + extra="ignore", ) diff --git a/libs/community/langchain_community/vectorstores/apache_doris.py b/libs/community/langchain_community/vectorstores/apache_doris.py index 07f72d1508dab..4d25f0a0aeb76 100644 --- a/libs/community/langchain_community/vectorstores/apache_doris.py +++ b/libs/community/langchain_community/vectorstores/apache_doris.py @@ -62,7 +62,10 @@ def __getitem__(self, item: str) -> Any: return getattr(self, item) model_config = SettingsConfigDict( - env_file=".env", env_file_encoding="utf-8", env_prefix="apache_doris_" + env_file=".env", + env_file_encoding="utf-8", + env_prefix="apache_doris_", + extra="ignore", ) diff --git a/libs/community/langchain_community/vectorstores/clickhouse.py b/libs/community/langchain_community/vectorstores/clickhouse.py index 83f5af6698b7e..a285cb8445210 100644 --- a/libs/community/langchain_community/vectorstores/clickhouse.py +++ b/libs/community/langchain_community/vectorstores/clickhouse.py @@ -96,7 +96,10 @@ def __getitem__(self, item: str) -> Any: return getattr(self, item) model_config = SettingsConfigDict( - env_file=".env", env_file_encoding="utf-8", env_prefix="clickhouse_" + env_file=".env", + env_file_encoding="utf-8", + env_prefix="clickhouse_", + extra="ignore", ) diff --git a/libs/community/langchain_community/vectorstores/kinetica.py b/libs/community/langchain_community/vectorstores/kinetica.py index 464f71de2c547..b9f987219b356 100644 --- a/libs/community/langchain_community/vectorstores/kinetica.py +++ b/libs/community/langchain_community/vectorstores/kinetica.py @@ -80,7 +80,10 @@ def __getitem__(self, item: str) -> Any: return getattr(self, item) model_config = SettingsConfigDict( - env_file=".env", env_file_encoding="utf-8", env_prefix="kinetica_" + env_file=".env", + env_file_encoding="utf-8", + env_prefix="kinetica_", + extra="ignore", ) diff --git a/libs/community/langchain_community/vectorstores/manticore_search.py b/libs/community/langchain_community/vectorstores/manticore_search.py index 4566189388fdc..3743e603da797 100644 --- a/libs/community/langchain_community/vectorstores/manticore_search.py +++ b/libs/community/langchain_community/vectorstores/manticore_search.py @@ -57,7 +57,10 @@ def __getitem__(self, item: str) -> Any: return getattr(self, item) model_config = SettingsConfigDict( - env_file=".env", env_file_encoding="utf-8", env_prefix="manticore_" + env_file=".env", + env_file_encoding="utf-8", + env_prefix="manticore_", + extra="ignore", ) diff --git a/libs/community/langchain_community/vectorstores/myscale.py b/libs/community/langchain_community/vectorstores/myscale.py index 8140840c6bbc6..ecd2108d419ba 100644 --- a/libs/community/langchain_community/vectorstores/myscale.py +++ b/libs/community/langchain_community/vectorstores/myscale.py @@ -86,7 +86,10 @@ def __getitem__(self, item: str) -> Any: return getattr(self, item) model_config = SettingsConfigDict( - env_file=".env", env_file_encoding="utf-8", env_prefix="myscale_" + env_file=".env", + env_file_encoding="utf-8", + env_prefix="myscale_", + extra="ignore", ) diff --git a/libs/community/langchain_community/vectorstores/starrocks.py b/libs/community/langchain_community/vectorstores/starrocks.py index f17d7b650fdaf..80debc09f92cd 100644 --- a/libs/community/langchain_community/vectorstores/starrocks.py +++ b/libs/community/langchain_community/vectorstores/starrocks.py @@ -113,7 +113,10 @@ def __getitem__(self, item: str) -> Any: return getattr(self, item) model_config = SettingsConfigDict( - env_file=".env", env_file_encoding="utf-8", env_prefix="starrocks_" + env_file=".env", + env_file_encoding="utf-8", + env_prefix="starrocks_", + extra="ignore", )