wikipedia
autogen.tools.experimental.wikipedia.wikipedia.WikipediaClient
WikipediaClient
Client for interacting with the Wikipedia API.
Supports searching and page retrieval on a specified language edition.
Public methods:
search(query: str, limit: int) -> list[dict[str, Any]]
get_page(title: str) -> Optional[wikipediaapi.WikipediaPage]
Attributes:
base_url (str): URL of the MediaWiki API endpoint.
headers (dict[str, str]): HTTP headers, including User-Agent.
wiki (wikipediaapi.Wikipedia): Low-level Wikipedia API client.
Initialize the WikipediaClient.
Name | Description |
---|---|
language | Type: str Default: ‘en’ |
tool_name | Type: str Default: ‘wikipedia-client’ |
Instance Methods
get_page
Retrieve a WikipediaPage object by title.
Name | Description |
---|---|
title | Title of the Wikipedia page. Type: str |
Type | Description |
---|---|
Any | None | wikipediaapi.WikipediaPage | None: The page object if it exists, otherwise None. |
search
Search Wikipedia for pages matching a query string.
Name | Description |
---|---|
query | The search keywords. Type: str |
limit | Max number of results to return. Type: int Default: 3 |
Type | Description |
---|---|
Any | list[dict[str, Any]]: Each dict has keys: - ‘title’ (str) - ‘size’ (int) - ‘wordcount’ (int) - ‘timestamp’ (str) |