mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-04 12:18:24 +00:00
Add support for wikipedia's lang parameter (#3383)
Allow to hange the language of the wikipedia API being requested. Co-authored-by: zhuohui <zhuohui@datastory.com.cn>
This commit is contained in:
parent
199cb855ea
commit
651cb62556
@ -240,7 +240,7 @@ _EXTRA_OPTIONAL_TOOLS = {
|
|||||||
"google-serper": (_get_google_serper, ["serper_api_key"]),
|
"google-serper": (_get_google_serper, ["serper_api_key"]),
|
||||||
"serpapi": (_get_serpapi, ["serpapi_api_key", "aiosession"]),
|
"serpapi": (_get_serpapi, ["serpapi_api_key", "aiosession"]),
|
||||||
"searx-search": (_get_searx_search, ["searx_host", "engines", "aiosession"]),
|
"searx-search": (_get_searx_search, ["searx_host", "engines", "aiosession"]),
|
||||||
"wikipedia": (_get_wikipedia, ["top_k_results"]),
|
"wikipedia": (_get_wikipedia, ["top_k_results", "lang"]),
|
||||||
"human": (_get_human_tool, ["prompt_func", "input_func"]),
|
"human": (_get_human_tool, ["prompt_func", "input_func"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ class WikipediaAPIWrapper(BaseModel):
|
|||||||
|
|
||||||
wiki_client: Any #: :meta private:
|
wiki_client: Any #: :meta private:
|
||||||
top_k_results: int = 3
|
top_k_results: int = 3
|
||||||
|
lang: str = "en"
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
"""Configuration for this pydantic object."""
|
"""Configuration for this pydantic object."""
|
||||||
@ -29,6 +30,7 @@ class WikipediaAPIWrapper(BaseModel):
|
|||||||
try:
|
try:
|
||||||
import wikipedia
|
import wikipedia
|
||||||
|
|
||||||
|
wikipedia.set_lang(values["lang"])
|
||||||
values["wiki_client"] = wikipedia
|
values["wiki_client"] = wikipedia
|
||||||
except ImportError:
|
except ImportError:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
Loading…
Reference in New Issue
Block a user