File size: 1,209 Bytes
f7b9b5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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)