Merge pull request #146 from Madhuvod/patch-2

feat: Updated investment_agent.py bugs
This commit is contained in:
Shubham Saboo 2025-03-17 21:12:04 -05:00 committed by GitHub
commit 5c3fb40382
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,31 +1,34 @@
# Import the required libraries
import streamlit as st import streamlit as st
from agno.agent import Agent from agno.agent import Agent
from agno.models.openai import OpenAIChat from agno.models.openai import OpenAIChat
from agno.tools.yfinance import YFinanceTools from agno.tools.yfinance import YFinanceTools
# Set up the Streamlit app
st.title("AI Investment Agent 📈🤖") st.title("AI Investment Agent 📈🤖")
st.caption("This app allows you to compare the performance of two stocks and generate detailed reports.") st.caption("This app allows you to compare the performance of two stocks and generate detailed reports.")
# Get OpenAI API key from user
openai_api_key = st.text_input("OpenAI API Key", type="password") openai_api_key = st.text_input("OpenAI API Key", type="password")
if openai_api_key: if openai_api_key:
# Create an instance of the Agent assistant = Agent(
agent = Agent( model=OpenAIChat(id="gpt-4o", api_key=openai_api_key),
llm=OpenAIChat(model="gpt-4o", api_key=openai_api_key), tools=[
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True)], YFinanceTools(stock_price=True, analyst_recommendations=True, stock_fundamentals=True)
],
show_tool_calls=True, show_tool_calls=True,
markdown=True description="You are an investment analyst that researches stock prices, analyst recommendations, and stock fundamentals.",
instructions=[
"Format your response using markdown and use tables to display data where possible."
],
) )
# Input fields for the stocks to compare col1, col2 = st.columns(2)
stock1 = st.text_input("Enter the first stock symbol") with col1:
stock2 = st.text_input("Enter the second stock symbol") stock1 = st.text_input("Enter first stock symbol (e.g. AAPL)")
with col2:
stock2 = st.text_input("Enter second stock symbol (e.g. MSFT)")
if stock1 and stock2: if stock1 and stock2:
# Get the response from the Agent with st.spinner(f"Analyzing {stock1} and {stock2}..."):
query = f"Compare {stock1} to {stock2}. Use every tool you have." query = f"Compare both the stocks - {stock1} and {stock2} and make a detailed report for an investment trying to invest and compare these stocks"
response = agent.run(query, stream=False) response = assistant.run(query, stream=False)
st.write(response.content) st.markdown(response.content)