mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-13 13:36:15 +00:00
community[patch]: update @root_validator in utilities namespace (#23768)
Update all utilities to use `pre=True` or `pre=False` https://github.com/langchain-ai/langchain/issues/22819
This commit is contained in:
@@ -26,13 +26,14 @@ class WikipediaAPIWrapper(BaseModel):
|
||||
load_all_available_meta: bool = False
|
||||
doc_content_chars_max: int = 4000
|
||||
|
||||
@root_validator()
|
||||
@root_validator(pre=True)
|
||||
def validate_environment(cls, values: Dict) -> Dict:
|
||||
"""Validate that the python package exists in environment."""
|
||||
try:
|
||||
import wikipedia
|
||||
|
||||
wikipedia.set_lang(values["lang"])
|
||||
lang = values.get("lang", "en")
|
||||
wikipedia.set_lang(lang)
|
||||
values["wiki_client"] = wikipedia
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
|
Reference in New Issue
Block a user