(phidata) william@beast61:~/phidata$ cat agent_team.py
from phi.agent import Agent
from phi.model.groq import Groq
from phi.tools.duckduckgo import DuckDuckGo
from phi.tools.yfinance import YFinanceTools
import os
os.environ[‘GROQ_API_KEY’] = “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”
web_agent = Agent(
name=“Web Agent”,
role=“Search the web for information”,
model=Groq(id=“llama-3.3-70b-versatile”),
tools=[DuckDuckGo()],
instructions=[“Always include sources”],
show_tool_calls=True,
markdown=True,
)
finance_agent = Agent(
name=“Finance Agent”,
role=“Get financial data”,
model=Groq(id=“llama-3.3-70b-versatile”),
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)],
instructions=[“Use tables to display data”],
show_tool_calls=True,
markdown=True,
)
agent_team = Agent(
team=[web_agent, finance_agent],
instructions=[“Always include sources”, “Use tables to display data”],
show_tool_calls=True,
markdown=True,
)
agent_team.print_response(“Summarize analyst recommendations and share the latest news for NVDA”, stream=True)
(phidata) william@beast61:~/phidata$ python agent_team.py
ERROR OPENAI_API_KEY not set. Please set the OPENAI_API_KEY environment variable.
▰▰▰▱▱▱▱ Thinking…
┏━ Message ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ┃
┃ Summarize analyst recommendations and share the latest news for NVDA ┃
┃ ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
Traceback (most recent call last):
File “/home/william/phidata/agent_team.py”, line 36, in
agent_team.print_response(“Summarize analyst recommendations and share the latest news for NVDA”, stream=True)
File “/home/william/anaconda3/envs/phidata/lib/python3.11/site-packages/phi/agent/agent.py”, line 2825, in print_response
for resp in self.run(message=message, messages=messages, stream=True, **kwargs):
File “/home/william/anaconda3/envs/phidata/lib/python3.11/site-packages/phi/agent/agent.py”, line 1805, in _run
for model_response_chunk in self.model.response_stream(messages=messages_for_model):
File “/home/william/anaconda3/envs/phidata/lib/python3.11/site-packages/phi/model/openai/chat.py”, line 872, in response_stream
for response in self.invoke_stream(messages=messages):
File “/home/william/anaconda3/envs/phidata/lib/python3.11/site-packages/phi/model/openai/chat.py”, line 396, in invoke_stream
yield from self.get_client().chat.completions.create(
^^^^^^^^^^^^^^^^^
File “/home/william/anaconda3/envs/phidata/lib/python3.11/site-packages/phi/model/openai/chat.py”, line 173, in get_client
return OpenAIClient(**client_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/william/anaconda3/envs/phidata/lib/python3.11/site-packages/openai/_client.py”, line 110, in init
raise OpenAIError(
openai.OpenAIError: The api_key client option must be set eithe