Spaces:
Sleeping
Sleeping
File size: 1,235 Bytes
0a072ae |
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 34 35 36 37 38 39 40 41 42 43 44 45 46 |
"""Run `pip install yfinance` to install dependencies."""
from phi.agent import Agent
from phi.model.groq import Groq
from phi.tools.yfinance import YFinanceTools
from dotenv import load_dotenv
load_dotenv()
def get_company_symbol(company: str) -> str:
"""Use this function to get the symbol for a company.
Args:
company (str): The name of the company.
Returns:
str: The symbol for the company.
"""
symbols = {
"Phidata": "MSFT",
"Infosys": "INFY",
"Tesla": "TSLA",
"Apple": "AAPL",
"Microsoft": "MSFT",
"Amazon": "AMZN",
"Google": "GOOGL",
}
return symbols.get(company, "Unknown")
agent = Agent(
model=Groq(id="llama-3.3-70b-versatile"),
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, stock_fundamentals=True), get_company_symbol],
instructions=[
"Use tables to display data.",
"If you need to find the symbol for a company, use the get_company_symbol tool.",
],
show_tool_calls=True,
markdown=True,
debug_mode=True,
)
agent.print_response(
"Summarize and compare analyst recommendations and fundamentals for TSLA and MSFT. Show in tables.", stream=True
) |