import wikipediaapi | |
def get_studio_albums(query): | |
# Use the Wikipedia API to search for the artist's studio albums | |
wiki = wikipediaapi.Wikipedia( | |
user_agent="FinalAssignmentAgent ([email protected])", | |
language="en", | |
# content_type="text", # "summary" or "text" | |
extract_format=wikipediaapi.ExtractFormat.WIKI, # "WIKI" or "HTML" | |
) | |
page = wiki.page(query) | |
if page.exists(): | |
return page.text | |
return "No information found." | |
artist_name = "Mercedes Sosa" | |
# studio_albums = get_studio_albums(artist_name) | |
# print(f"The artist {artist_name} published {studio_albums} studio albums between 2000 and 2009.") | |
from smolagents import CodeAgent, ToolCallingAgent, TransformersModel, VisitWebpageTool, PythonInterpreterTool, WebSearchTool, WikipediaSearchTool, FinalAnswerTool, Tool, tool # InferenceClientModel, GoogleSearchTool (usa SERPAPI_API_KEY), DuckDuckGoSearchTool | |
model_id = "HuggingFaceTB/SmolLM2-1.7B-Instruct" | |
model = TransformersModel(model_id=model_id, trust_remote_code=True, max_new_tokens=4096) | |
agent = CodeAgent( | |
model=model, | |
tools=[ | |
WebSearchTool(), | |
VisitWebpageTool(), | |
PythonInterpreterTool(), | |
FinalAnswerTool(), | |
], | |
) | |
print(agent.prompt_templates) |