Final_Assignment_Agents / smolagents_test_new.py
Gonzalo Lope
fixed imports and added a wikipedia and reverse string tool
ee1ba96
raw
history blame
637 Bytes
from huggingface_hub import login
from smolagents import CodeAgent, InferenceClientModel, DuckDuckGoSearchTool, WikipediaSearchTool
from smolagents import tool
@tool
def reverse_string(input_string: str) -> str:
"""This is a tool that given a string, returns the reversed string.
Args:
input_string (str): The string to reverse.
"""
return input_string[::-1]
agent = CodeAgent(tools=[DuckDuckGoSearchTool(),reverse_string,WikipediaSearchTool()], model=InferenceClientModel())
if __name__ == "__main__":
agent.run("Search for the best music recommendations for a party at the Wayne's mansion.")