Skip to content

Commit 651cb62

Browse files
zczhuohuozhuohui
andauthored
Add support for wikipedia's lang parameter (langchain-ai#3383)
Allow to hange the language of the wikipedia API being requested. Co-authored-by: zhuohui <zhuohui@datastory.com.cn>
1 parent 199cb85 commit 651cb62

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

langchain/agents/load_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def _get_human_tool(**kwargs: Any) -> BaseTool:
240240
"google-serper": (_get_google_serper, ["serper_api_key"]),
241241
"serpapi": (_get_serpapi, ["serpapi_api_key", "aiosession"]),
242242
"searx-search": (_get_searx_search, ["searx_host", "engines", "aiosession"]),
243-
"wikipedia": (_get_wikipedia, ["top_k_results"]),
243+
"wikipedia": (_get_wikipedia, ["top_k_results", "lang"]),
244244
"human": (_get_human_tool, ["prompt_func", "input_func"]),
245245
}
246246

langchain/utilities/wikipedia.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class WikipediaAPIWrapper(BaseModel):
1717

1818
wiki_client: Any #: :meta private:
1919
top_k_results: int = 3
20+
lang: str = "en"
2021

2122
class Config:
2223
"""Configuration for this pydantic object."""
@@ -29,6 +30,7 @@ def validate_environment(cls, values: Dict) -> Dict:
2930
try:
3031
import wikipedia
3132

33+
wikipedia.set_lang(values["lang"])
3234
values["wiki_client"] = wikipedia
3335
except ImportError:
3436
raise ValueError(

0 commit comments

Comments
 (0)