File size: 555 Bytes
49e6624
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# agent.py
from smolagents import ToolCallingAgent
from smolagents.models import HfApiModel
from smolagents.tools import tool
import requests

@tool
def get_stock_price(ticker: str) -> str:
    # (same code as above)
    ...

model = HfApiModel(model_id="mistralai/Mistral-7B-Instruct-v0.2")

agent = ToolCallingAgent(
    tools=[get_stock_price],
    model=model,
    max_steps=3,
    name="stock_price_agent",
    description="Gets real-time stock prices for a given ticker."
)

def answer_question(question: str) -> str:
    return agent.run(question)