Ashkchamp commited on
Commit
4ef9581
·
verified ·
1 Parent(s): 16db796

Upload 2 files

Browse files
Files changed (2) hide show
  1. __init__.py +3 -0
  2. app.py +68 -0
__init__.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # utils/__init__.py
2
+
3
+ # This file is intentionally left blank.
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import pandas as pd
4
+ import yfinance as yf
5
+ import matplotlib.pyplot as plt
6
+ from agno.agent import Agent
7
+ from agno.models.groq import Groq
8
+ from agno.tools.yfinance import YFinanceTools
9
+ from agno.tools.duckduckgo import DuckDuckGoTools
10
+ import groq
11
+ from dotenv import load_dotenv
12
+ import time
13
+
14
+ # Load environment variables first
15
+ load_dotenv()
16
+
17
+ # Check if API key exists and set it manually if needed
18
+ if not os.getenv("GROQ_API_KEY"):
19
+ st.error("GROQ_API_KEY not found in environment variables. Please add it to your .env file.")
20
+ st.stop()
21
+
22
+ # Set API key explicitly
23
+ groq.api_key = os.getenv("GROQ_API_KEY")
24
+
25
+ # Import agent modules after setting API key
26
+ from agents.finance_agent import FinanceAgent
27
+
28
+ # Initialize only the finance agent first
29
+ finance_agent = FinanceAgent()
30
+
31
+ # Streamlit app title
32
+ st.title("Finance Agent App")
33
+
34
+ # User input for stock ticker
35
+ ticker_symbol = st.text_input("Enter Stock Ticker Symbol (e.g., TSLA):", "TSLA")
36
+
37
+ if st.button("Get Financial Insights"):
38
+ if ticker_symbol:
39
+ try:
40
+ # First display a comprehensive report
41
+ with st.spinner(f"Generating comprehensive financial report for {ticker_symbol}..."):
42
+ st.subheader(f"📊 Comprehensive Financial Report for {ticker_symbol}")
43
+ comprehensive_report = finance_agent.generate_comprehensive_report(ticker_symbol)
44
+ st.markdown(comprehensive_report.content)
45
+
46
+ # Then show historical price chart
47
+ with st.spinner(f"Retrieving historical price data for {ticker_symbol}..."):
48
+ st.subheader(f"📈 Historical Stock Price Data for {ticker_symbol}")
49
+ historical_data = finance_agent.get_historical_price_data(ticker_symbol)
50
+ st.line_chart(historical_data['Close'])
51
+
52
+ # Add a divider
53
+ st.markdown("---")
54
+
55
+ # Include expand sections for detailed information
56
+ with st.expander(f"Detailed Stock Fundamentals for {ticker_symbol}"):
57
+ fundamentals_response = finance_agent.get_stock_fundamentals(ticker_symbol)
58
+ st.markdown(fundamentals_response.content)
59
+
60
+ with st.expander(f"Analyst Recommendations for {ticker_symbol}"):
61
+ analyst_response = finance_agent.get_analyst_recommendations_and_news(ticker_symbol)
62
+ st.markdown(analyst_response.content)
63
+
64
+ except Exception as e:
65
+ st.error(f"An error occurred: {str(e)}")
66
+ st.info("Try again or use a different ticker symbol")
67
+ else:
68
+ st.error("Please enter a valid stock ticker symbol.")