Merge pull request #146 from Madhuvod/patch-2
feat: Updated investment_agent.py bugs
This commit is contained in:
commit
5c3fb40382
1 changed files with 18 additions and 15 deletions
|
|
@ -1,31 +1,34 @@
|
|||
# Import the required libraries
|
||||
import streamlit as st
|
||||
from agno.agent import Agent
|
||||
from agno.models.openai import OpenAIChat
|
||||
from agno.tools.yfinance import YFinanceTools
|
||||
|
||||
# Set up the Streamlit app
|
||||
st.title("AI Investment Agent 📈🤖")
|
||||
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")
|
||||
|
||||
if openai_api_key:
|
||||
# Create an instance of the Agent
|
||||
agent = Agent(
|
||||
llm=OpenAIChat(model="gpt-4o", api_key=openai_api_key),
|
||||
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True, company_news=True)],
|
||||
assistant = Agent(
|
||||
model=OpenAIChat(id="gpt-4o", api_key=openai_api_key),
|
||||
tools=[
|
||||
YFinanceTools(stock_price=True, analyst_recommendations=True, stock_fundamentals=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
|
||||
stock1 = st.text_input("Enter the first stock symbol")
|
||||
stock2 = st.text_input("Enter the second stock symbol")
|
||||
col1, col2 = st.columns(2)
|
||||
with col1:
|
||||
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:
|
||||
# Get the response from the Agent
|
||||
query = f"Compare {stock1} to {stock2}. Use every tool you have."
|
||||
response = agent.run(query, stream=False)
|
||||
st.write(response.content)
|
||||
with st.spinner(f"Analyzing {stock1} and {stock2}..."):
|
||||
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 = assistant.run(query, stream=False)
|
||||
st.markdown(response.content)
|
||||
|
|
|
|||
Loading…
Reference in a new issue