|
|
from smolagents import Tool |
|
|
from my_base_wiki_api import MyWikiAPI |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MyWikiFeaturedArticles(Tool): |
|
|
name = "_my_tool_wiki_featured_articles" |
|
|
description = """ |
|
|
Extracts a list of nominators and summaries of featured Wikipedia articles for the provided month and year |
|
|
To invoke the tool use code as below |
|
|
<code> |
|
|
featured_articles = _my_tool_wiki_featured_articles(month='January', year=2005) |
|
|
</code> |
|
|
""" |
|
|
|
|
|
inputs = { |
|
|
"month": { |
|
|
"type": "string", |
|
|
"description": "name of the month for example January", |
|
|
}, |
|
|
"year": { |
|
|
"type": "integer", |
|
|
"description": "Year expressed in 4 digit notation, for example 2009", |
|
|
}, |
|
|
} |
|
|
|
|
|
output_type = "string" |
|
|
|
|
|
is_initialized = True |
|
|
|
|
|
def __init__(self): |
|
|
print(f"***KS*** Wiki featured articles tool initializing ...") |
|
|
self.wiki = MyWikiAPI() |
|
|
|
|
|
def forward(self, month, year): |
|
|
result = self.wiki.get_featured_articles(month, year) |
|
|
return result |
|
|
|