Skip to content

Instantly share code, notes, and snippets.

@amosgyamfi
Created December 7, 2024 16:52
Show Gist options
  • Save amosgyamfi/a5a2c7afe362675feae8f237fe84d87e to your computer and use it in GitHub Desktop.
Save amosgyamfi/a5a2c7afe362675feae8f237fe84d87e to your computer and use it in GitHub Desktop.
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