langchain_community.utilities.wikidata.WikidataAPIWrapper¶

class langchain_community.utilities.wikidata.WikidataAPIWrapper[source]¶

Bases: BaseModel

Wrapper around the Wikidata API.

To use, you should have the wikibase-rest-api-client and ``mediawikiapi `` python packages installed. This wrapper will use the Wikibase APIs to conduct searches and fetch item content. By default, it will return the item content of the top-k results. It limits the Document content by doc_content_chars_max.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param doc_content_chars_max: int = 4000¶
param lang: str = 'en'¶
param load_all_available_meta: bool = False¶
param top_k_results: int = 2¶
param wikidata_props: List[str] = ['P31', 'P279', 'P27', 'P361', 'P527', 'P495', 'P17', 'P585', 'P131', 'P106', 'P21', 'P569', 'P570', 'P577', 'P50', 'P571', 'P641', 'P625', 'P19', 'P69', 'P108', 'P136', 'P39', 'P161', 'P20', 'P101', 'P179', 'P175', 'P7937', 'P57', 'P607', 'P509', 'P800', 'P449', 'P580', 'P582', 'P276', 'P69', 'P112', 'P740', 'P159', 'P452', 'P102', 'P1142', 'P1387', 'P1576', 'P140', 'P178', 'P287', 'P25', 'P22', 'P40', 'P185', 'P802', 'P1416']¶
param wikidata_rest: Any = None¶
load(query: str) List[Document][source]¶

Run Wikidata search and get the item documents plus the meta information.

Parameters

query (str) –

Return type

List[Document]

run(query: str) str[source]¶

Run Wikidata search and get item summaries.

Parameters

query (str) –

Return type

str

Examples using WikidataAPIWrapper¶