This agent was used with a duplicated space of the first_agent_template space provided with the HuggingFace Agents (smolagents) course: https://huggingface.co/spaces/agents-course/First_agent_template/tree/main It uses Yahoo Finance to get five news items (title, date, publisher, url) for a specified stock and the latest closing value.
The agent is defined in file get_stock_news.py and would normally be placed in the tools subfolder.
In the main script (e.g., app.py) you would include the following:
from tools.get_stock_news import StockNewsTool
stock_news_items = StockNewsTool()
agent = CodeAgent( model=model, tools=[final_answer, stock_news_items], ## add your tools here (don't remove final answer) (etc.)
Also: I added "stock_news_items" to the "tools" list in file agents.json