Skip to content

Commit 29acf97

Browse files
committed
phidata first tutorial
1 parent 7ee4896 commit 29acf97

File tree

4 files changed

+98
-1
lines changed

4 files changed

+98
-1
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,5 @@ cython_debug/
159159
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160160
# and can be added to the global gitignore or merged into this file. For a more nuclear
161161
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162-
#.idea/
162+
.idea/
163+
DoNotUpload
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from phi.agent import Agent
2+
from phi.model.groq import Groq
3+
from dotenv import load_dotenv
4+
5+
load_dotenv()
6+
7+
agent = Agent(
8+
model=Groq(id="llama-3.3-70b-versatile")
9+
)
10+
11+
agent.print_response("Share a 2 sentence love story between dosa and samosa")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
"""Run `pip install yfinance` to install dependencies."""
2+
3+
from phi.agent import Agent
4+
from phi.model.groq import Groq
5+
from phi.tools.yfinance import YFinanceTools
6+
from dotenv import load_dotenv
7+
8+
load_dotenv()
9+
10+
11+
def get_company_symbol(company: str) -> str:
12+
"""Use this function to get the symbol for a company.
13+
14+
Args:
15+
company (str): The name of the company.
16+
17+
Returns:
18+
str: The symbol for the company.
19+
"""
20+
symbols = {
21+
"Phidata": "MSFT",
22+
"Infosys": "INFY",
23+
"Tesla": "TSLA",
24+
"Apple": "AAPL",
25+
"Microsoft": "MSFT",
26+
"Amazon": "AMZN",
27+
"Google": "GOOGL",
28+
}
29+
return symbols.get(company, "Unknown")
30+
31+
32+
agent = Agent(
33+
model=Groq(id="llama-3.3-70b-versatile"),
34+
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, stock_fundamentals=True), get_company_symbol],
35+
instructions=[
36+
"Use tables to display data.",
37+
"If you need to find the symbol for a company, use the get_company_symbol tool.",
38+
],
39+
show_tool_calls=True,
40+
markdown=True,
41+
debug_mode=True,
42+
)
43+
44+
agent.print_response(
45+
"Summarize and compare analyst recommendations and fundamentals for TSLA and Phidata. Show in tables.", stream=True
46+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
from phi.agent import Agent
2+
from phi.model.openai import OpenAIChat
3+
from phi.model.groq import Groq
4+
from phi.tools.duckduckgo import DuckDuckGo
5+
from phi.tools.yfinance import YFinanceTools
6+
from dotenv import load_dotenv
7+
8+
load_dotenv()
9+
10+
web_agent = Agent(
11+
name="Web Agent",
12+
model=Groq(id="llama-3.3-70b-versatile"),
13+
# model=OpenAIChat(id="gpt-4o"),
14+
tools=[DuckDuckGo()],
15+
instructions=["Always include sources"],
16+
show_tool_calls=True,
17+
markdown=True
18+
)
19+
20+
finance_agent = Agent(
21+
name="Finance Agent",
22+
role="Get financial data",
23+
model=Groq(id="llama-3.3-70b-versatile"),
24+
# model=OpenAIChat(id="gpt-4o"),
25+
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)],
26+
instructions=["Use tables to display data"],
27+
show_tool_calls=True,
28+
markdown=True,
29+
)
30+
31+
agent_team = Agent(
32+
model=Groq(id="llama-3.3-70b-versatile"),
33+
team=[web_agent, finance_agent],
34+
instructions=["Always include sources", "Use tables to display data"],
35+
show_tool_calls=True,
36+
markdown=True,
37+
)
38+
39+
agent_team.print_response("Summarize analyst recommendations and share the latest news for NVDA", stream=True)

0 commit comments

Comments
 (0)