This project leverages Phi and Groq models to create a multi-agent system capable of performing web searches and retrieving financial data. The purpose of this system is to automate the gathering and analysis of financial data, empowering users with timely and accurate insights for making informed decisions. The system uses a combination of web search tools (DuckDuckGo) and financial data tools (Yahoo Finance) to gather valuable information, such as stock prices, analyst recommendations, company news, and more. The agents work together to fulfill queries related to finance and other domains.
Start by cloning this repository to your local machine.
git clone https://github.com/GaganaMD/Financial-Agent-With-Phidata.git
cd Financial-Agent-With-PhidataIt is recommended to use a virtual environment to manage the dependencies for the project.
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`Once the virtual environment is activated, install the necessary dependencies.
pip install -r requirements.txtThis project requires the following Python packages:
phi: A library for fluent functional programming and creating intelligent agents.dotenv: A library for managing environment variables.yfinance: To retrieve financial data like stock prices, news, and analyst recommendations.duckduckgo-search: A library for DuckDuckGo web searches.openai: The library for OpenAI API integration.
You can install them using the requirements.txt file that lists these dependencies.
Before running the program, you need to set up your environment with the required API keys. You need an OpenAI API key for Groq models.
To do this:
- Create a
.envfile in the project root. - Add your groq and phi API keys as follows:
PHI_API_KEY=your-openai-api-key-here GROQ_API_KEY=your-openai-api-key-here
git
The .env file should be loaded automatically with dotenv when the script is run.
The system uses the following tools:
- Web Search Agent: This agent uses DuckDuckGo for querying web search results.
- Finance AI Agent: This agent uses Yahoo Finance tools to gather financial data, including:
- Stock Price
- Analyst Recommendations
- Stock Fundamentals
- Company News
- Stock History
- Stock Options
You can customize these agents by modifying their respective configurations in the script.
-
Start the agent system:
The multi-agent system performs actions through a combination of the
websearch_agentandfinancial_agent. Here's how you can trigger the system:multi_agent_system.print_response("Summarise analyst recommendations and share the latest news for NVDA", stream=True)
This query will instruct the agents to gather and summarize information on NVIDIA (NVDA), including analyst recommendations and the latest company news.
You can modify the query string passed to multi_agent_system.print_response() to get different financial or web data. For example:
multi_agent_system.print_response("What is the latest stock news for AAPL?", stream=True)You can change the settings of each agent, such as the role, model, instructions, and tools used. For example:
- Change the model used by the agents to a different Groq model or any other compatible model.
- Modify the instructions to customize how the agents behave when responding to queries.
Here is an example of the recommendation generated by the agent:
This project is licensed under the Apache 2.0 License. See the LICENSE file for more details.
