Deaksh commited on
Commit
0a072ae
·
verified ·
1 Parent(s): 7800408

Upload 5 files

Browse files
Files changed (5) hide show
  1. 2.finance_agent.py +46 -0
  2. 3-agent-team.py +39 -0
  3. Groq-AI-Agent.py +11 -0
  4. agents.db +0 -0
  5. playground.py +33 -0
2.finance_agent.py ADDED
@@ -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 MSFT. Show in tables.", stream=True
46
+ )
3-agent-team.py ADDED
@@ -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="pip install pandas"),
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)
Groq-AI-Agent.py ADDED
@@ -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")
agents.db ADDED
File without changes
playground.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from phi.agent import Agent
2
+ from phi.model.openai import OpenAIChat
3
+ from phi.storage.agent.sqlite import SqlAgentStorage
4
+ from phi.tools.duckduckgo import DuckDuckGo
5
+ from phi.tools.yfinance import YFinanceTools
6
+ from phi.playground import Playground, serve_playground_app
7
+
8
+
9
+ web_agent = Agent(
10
+ name="Web Agent",
11
+ model=OpenAIChat(id="gpt-4o"),
12
+ tools=[DuckDuckGo()],
13
+ instructions=["Always include sources"],
14
+ storage=SqlAgentStorage(table_name="web_agent", db_file="agents.db"),
15
+ add_history_to_messages=True,
16
+ markdown=True,
17
+ )
18
+
19
+ finance_agent = Agent(
20
+ name="Finance Agent",
21
+ model=OpenAIChat(id="gpt-4o"),
22
+ tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True)],
23
+ instructions=["Use tables to display data"],
24
+ storage=SqlAgentStorage(table_name="finance_agent", db_file="agents.db"),
25
+ add_history_to_messages=True,
26
+ markdown=True,
27
+ )
28
+
29
+ app = Playground(agents=[finance_agent, web_agent]).get_app()
30
+
31
+
32
+ if __name__ == "__main__":
33
+ serve_playground_app("playground:app", reload=True)