From 61ae5baefc86c8d1fd0908a76d9be4e8cdc34aec Mon Sep 17 00:00:00 2001 From: ShubhamSaboo Date: Mon, 21 Oct 2024 20:16:24 -0500 Subject: [PATCH] Added new demo --- ai_finance_agent_team/README.md | 39 ++++++++++++++++++++ ai_finance_agent_team/finance_agent_team.py | 40 +++++++++++++++++++++ ai_finance_agent_team/requirements.txt | 6 ++++ 3 files changed, 85 insertions(+) create mode 100644 ai_finance_agent_team/README.md create mode 100644 ai_finance_agent_team/finance_agent_team.py create mode 100644 ai_finance_agent_team/requirements.txt diff --git a/ai_finance_agent_team/README.md b/ai_finance_agent_team/README.md new file mode 100644 index 0000000..35a6391 --- /dev/null +++ b/ai_finance_agent_team/README.md @@ -0,0 +1,39 @@ +## 💲 AI Finance Agent Team with Web Access +This script demonstrates how to build a team of AI agents that work together as a financial analyst using GPT-4o in just 20 lines of Python code. The system combines web search capabilities with financial data analysis tools to provide comprehensive financial insights. + +### Features +- Multi-agent system with specialized roles: + - Web Agent for general internet research + - Finance Agent for detailed financial analysis + - Team Agent for coordinating between agents +- Real-time financial data access through YFinance +- Web search capabilities using DuckDuckGo +- Persistent storage of agent interactions using SQLite + +### How to get Started? + +1. Clone the GitHub repository +```bash +git clone https://github.com/Shubhamsaboo/awesome-llm-apps.git +``` + +2. Install the required dependencies: + +```bash +pip install -r requirements.txt +``` + +3. Get your OpenAI API Key + +- Sign up for an [OpenAI account](https://platform.openai.com/) (or the LLM provider of your choice) and obtain your API key. +- Set your OpenAI API key as an environment variable: +```bash +export OPENAI_API_KEY='your-api-key-here' +``` + +4. Run the team of AI Agents +```bash +python3 finance_agent_team.py +``` + +5. Open your web browser and navigate to the URL provided in the console output to interact with the team of AI agents through the playground interface. diff --git a/ai_finance_agent_team/finance_agent_team.py b/ai_finance_agent_team/finance_agent_team.py new file mode 100644 index 0000000..f8aa3b3 --- /dev/null +++ b/ai_finance_agent_team/finance_agent_team.py @@ -0,0 +1,40 @@ +from phi.agent import Agent +from phi.model.openai import OpenAIChat +from phi.storage.agent.sqlite import SqlAgentStorage +from phi.tools.duckduckgo import DuckDuckGo +from phi.tools.yfinance import YFinanceTools +from phi.playground import Playground, serve_playground_app + +web_agent = Agent( + name="Web Agent", + role="Search the web for information", + model=OpenAIChat(id="gpt-4o"), + tools=[DuckDuckGo()], + storage=SqlAgentStorage(table_name="web_agent", db_file="agents.db"), + add_history_to_messages=True, + markdown=True, +) + +finance_agent = Agent( + name="Finance Agent", + role="Get financial data", + model=OpenAIChat(id="gpt-4o"), + tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True)], + instructions=["Always use tables to display data"], + storage=SqlAgentStorage(table_name="finance_agent", db_file="agents.db"), + add_history_to_messages=True, + markdown=True, +) + +agent_team = Agent( + team=[web_agent, finance_agent], + name="Agent Team (Web+Finance)", + model=OpenAIChat(id="gpt-4o"), + show_tool_calls=True, + markdown=True, +) + +app = Playground(agents=[agent_team]).get_app() + +if __name__ == "__main__": + serve_playground_app("finance_agent_team:app", reload=True) \ No newline at end of file diff --git a/ai_finance_agent_team/requirements.txt b/ai_finance_agent_team/requirements.txt new file mode 100644 index 0000000..0638842 --- /dev/null +++ b/ai_finance_agent_team/requirements.txt @@ -0,0 +1,6 @@ +openai +phidata +duckduckgo-search +yfinance +fastapi[standard] +sqlalchemy \ No newline at end of file