Created
December 7, 2024 16:52
-
-
Save amosgyamfi/a5a2c7afe362675feae8f237fe84d87e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import openai | |
from phi.agent import Agent | |
from phi.model.openai import OpenAIChat | |
from phi.tools.yfinance import YFinanceTools | |
from dotenv import load_dotenv | |
import os | |
# Load environment variables from .env file | |
load_dotenv() | |
# Get API key from environment | |
openai.api_key = os.getenv("OPENAI_API_KEY") | |
# Initialize the agent | |
finance_agent = Agent( | |
name="Finance AI Agent", | |
model=OpenAIChat(id="gpt-4o"), | |
tools=[ | |
YFinanceTools( | |
stock_price=True, | |
analyst_recommendations=True, | |
company_info=True, | |
company_news=True, | |
) | |
], | |
instructions=["Use tables to display data"], | |
show_tool_calls=True, | |
markdown=True, | |
) | |
finance_agent.print_response("Summarize analyst recommendations for Tesla", stream=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment