Added new demo
This commit is contained in:
parent
835dfd66be
commit
61ae5baefc
3 changed files with 85 additions and 0 deletions
39
ai_finance_agent_team/README.md
Normal file
39
ai_finance_agent_team/README.md
Normal file
|
|
@ -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.
|
||||||
40
ai_finance_agent_team/finance_agent_team.py
Normal file
40
ai_finance_agent_team/finance_agent_team.py
Normal file
|
|
@ -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)
|
||||||
6
ai_finance_agent_team/requirements.txt
Normal file
6
ai_finance_agent_team/requirements.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
openai
|
||||||
|
phidata
|
||||||
|
duckduckgo-search
|
||||||
|
yfinance
|
||||||
|
fastapi[standard]
|
||||||
|
sqlalchemy
|
||||||
Loading…
Reference in a new issue