Aravindram commited on
Commit
49e6624
·
verified ·
1 Parent(s): 8c5c24b

Create agent.py

Browse files
Files changed (1) hide show
  1. agent.py +23 -0
agent.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # agent.py
2
+ from smolagents import ToolCallingAgent
3
+ from smolagents.models import HfApiModel
4
+ from smolagents.tools import tool
5
+ import requests
6
+
7
+ @tool
8
+ def get_stock_price(ticker: str) -> str:
9
+ # (same code as above)
10
+ ...
11
+
12
+ model = HfApiModel(model_id="mistralai/Mistral-7B-Instruct-v0.2")
13
+
14
+ agent = ToolCallingAgent(
15
+ tools=[get_stock_price],
16
+ model=model,
17
+ max_steps=3,
18
+ name="stock_price_agent",
19
+ description="Gets real-time stock prices for a given ticker."
20
+ )
21
+
22
+ def answer_question(question: str) -> str:
23
+ return agent.run(question)