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>
fix_agent_callbacks
zz 1 year ago committed by GitHub
parent 199cb855ea
commit 651cb62556
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -240,7 +240,7 @@ _EXTRA_OPTIONAL_TOOLS = {
"google-serper": (_get_google_serper, ["serper_api_key"]),
"serpapi": (_get_serpapi, ["serpapi_api_key", "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"]),
}

@ -17,6 +17,7 @@ class WikipediaAPIWrapper(BaseModel):
wiki_client: Any #: :meta private:
top_k_results: int = 3
lang: str = "en"
class Config:
"""Configuration for this pydantic object."""
@ -29,6 +30,7 @@ class WikipediaAPIWrapper(BaseModel):
try:
import wikipedia
wikipedia.set_lang(values["lang"])
values["wiki_client"] = wikipedia
except ImportError:
raise ValueError(

Loading…
Cancel
Save