agentscope.service.web.wikipedia module
Search contents from WikiPedia
- agentscope.service.web.wikipedia.wikipedia_search_categories(query: str, max_members: int = 1000) ServiceResponse [source]
Retrieve categories from Wikipedia:Category pages.
- Parameters:
query (str) – The given searching keywords
max_members (int) – The maximum number of members to output
- Returns:
A response that contains the execution status and returned content. In the returned content, the meanings of keys:
”pageid”: unique page ID for the member
”ns”: namespace for the member
”title”: title of the member
Example:
members = wiki_get_category_members( "Machine_learning", max_members=10 ) print(members)
It returns contents:
{ 'status': <ServiceExecStatus.SUCCESS: 1>, 'content': [ { 'pageid': 67911196, 'ns': 0, 'title': 'Bayesian learning mechanisms' }, { 'pageid': 233488, 'ns': 0, 'title': 'Machine learning' }, # ... ] }
- Return type:
ServiceResponse
- agentscope.service.web.wikipedia.wikipedia_search(query: str) ServiceResponse [source]
Search the given query in Wikipedia. Note the returned text maybe related entities, which means you should adjust your query as needed and search again.
Note the returned text maybe too long for some llm, it’s recommended to summarize the returned text first.
- Parameters:
query (str) – The searched query in wikipedia.
- Returns:
A response that contains the execution status and returned content.
- Return type:
ServiceResponse