Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,84 +1,84 @@
|
|
| 1 |
-
from crewai import Crew
|
| 2 |
-
from textwrap import dedent
|
| 3 |
-
import streamlit as st
|
| 4 |
-
from stock_analysis_agents import StockAnalysisAgents
|
| 5 |
-
from stock_analysis_tasks import StockAnalysisTasks
|
| 6 |
-
import os
|
| 7 |
-
|
| 8 |
-
class FinancialCrew:
|
| 9 |
-
def __init__(self, company):
|
| 10 |
-
self.company = company
|
| 11 |
-
|
| 12 |
-
def run(self):
|
| 13 |
-
agents = StockAnalysisAgents()
|
| 14 |
-
tasks = StockAnalysisTasks()
|
| 15 |
-
|
| 16 |
-
research_analyst_agent = agents.research_analyst()
|
| 17 |
-
financial_analyst_agent = agents.financial_analyst()
|
| 18 |
-
investment_advisor_agent = agents.investment_advisor()
|
| 19 |
-
|
| 20 |
-
research_task = tasks.research(research_analyst_agent, self.company)
|
| 21 |
-
financial_task = tasks.financial_analysis(financial_analyst_agent)
|
| 22 |
-
filings_task = tasks.filings_analysis(financial_analyst_agent)
|
| 23 |
-
recommend_task = tasks.recommend(investment_advisor_agent)
|
| 24 |
-
|
| 25 |
-
crew = Crew(
|
| 26 |
-
agents=[
|
| 27 |
-
research_analyst_agent,
|
| 28 |
-
financial_analyst_agent,
|
| 29 |
-
investment_advisor_agent
|
| 30 |
-
],
|
| 31 |
-
tasks=[
|
| 32 |
-
research_task,
|
| 33 |
-
financial_task,
|
| 34 |
-
filings_task,
|
| 35 |
-
recommend_task
|
| 36 |
-
],
|
| 37 |
-
verbose=True
|
| 38 |
-
)
|
| 39 |
-
|
| 40 |
-
result = crew.kickoff()
|
| 41 |
-
return result
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
def main():
|
| 45 |
-
st.set_page_config(page_title="Stock Market Analyzer", page_icon="📈")
|
| 46 |
-
|
| 47 |
-
st.title("Stock Market Analyzer")
|
| 48 |
-
|
| 49 |
-
# Project details
|
| 50 |
-
st.markdown("""
|
| 51 |
-
This Stock Market Analyzer uses CrewAI to generate detailed reports on companies.
|
| 52 |
-
It leverages multiple AI agents to perform comprehensive analysis:
|
| 53 |
-
- Research Analyst: Gathers general information about the company
|
| 54 |
-
- Financial Analyst: Analyzes financial data and SEC filings
|
| 55 |
-
- Investment Advisor: Provides investment recommendations
|
| 56 |
-
""")
|
| 57 |
-
|
| 58 |
-
# API Key inputs
|
| 59 |
-
gemini_api = st.sidebar.text_input("Enter your Gemini API Key:", type="password")
|
| 60 |
-
serper_api = st.sidebar.text_input("Enter your Serper API Key:", type="password")
|
| 61 |
-
sec_api = st.sidebar.text_input("Enter your SEC API Key:", type="password")
|
| 62 |
-
|
| 63 |
-
# Set environment variables
|
| 64 |
-
os.environ['
|
| 65 |
-
os.environ['SERPER_API_KEY'] = serper_api
|
| 66 |
-
os.environ['SEC_API_KEY'] = sec_api
|
| 67 |
-
|
| 68 |
-
# Company input
|
| 69 |
-
company = st.text_input("Enter the company name you want to analyze:")
|
| 70 |
-
|
| 71 |
-
if st.button("Analyze"):
|
| 72 |
-
if company and gemini_api and serper_api and sec_api:
|
| 73 |
-
with st.spinner("Analyzing... This may take a few minutes."):
|
| 74 |
-
financial_crew = FinancialCrew(company)
|
| 75 |
-
result = financial_crew.run()
|
| 76 |
-
|
| 77 |
-
st.success("Analysis complete!")
|
| 78 |
-
st.subheader("Analysis Report")
|
| 79 |
-
st.markdown(result)
|
| 80 |
-
else:
|
| 81 |
-
st.warning("Please enter all required information (API keys and company name).")
|
| 82 |
-
|
| 83 |
-
if __name__ == "__main__":
|
| 84 |
main()
|
|
|
|
| 1 |
+
from crewai import Crew
|
| 2 |
+
from textwrap import dedent
|
| 3 |
+
import streamlit as st
|
| 4 |
+
from stock_analysis_agents import StockAnalysisAgents
|
| 5 |
+
from stock_analysis_tasks import StockAnalysisTasks
|
| 6 |
+
import os
|
| 7 |
+
|
| 8 |
+
class FinancialCrew:
|
| 9 |
+
def __init__(self, company):
|
| 10 |
+
self.company = company
|
| 11 |
+
|
| 12 |
+
def run(self):
|
| 13 |
+
agents = StockAnalysisAgents()
|
| 14 |
+
tasks = StockAnalysisTasks()
|
| 15 |
+
|
| 16 |
+
research_analyst_agent = agents.research_analyst()
|
| 17 |
+
financial_analyst_agent = agents.financial_analyst()
|
| 18 |
+
investment_advisor_agent = agents.investment_advisor()
|
| 19 |
+
|
| 20 |
+
research_task = tasks.research(research_analyst_agent, self.company)
|
| 21 |
+
financial_task = tasks.financial_analysis(financial_analyst_agent)
|
| 22 |
+
filings_task = tasks.filings_analysis(financial_analyst_agent)
|
| 23 |
+
recommend_task = tasks.recommend(investment_advisor_agent)
|
| 24 |
+
|
| 25 |
+
crew = Crew(
|
| 26 |
+
agents=[
|
| 27 |
+
research_analyst_agent,
|
| 28 |
+
financial_analyst_agent,
|
| 29 |
+
investment_advisor_agent
|
| 30 |
+
],
|
| 31 |
+
tasks=[
|
| 32 |
+
research_task,
|
| 33 |
+
financial_task,
|
| 34 |
+
filings_task,
|
| 35 |
+
recommend_task
|
| 36 |
+
],
|
| 37 |
+
verbose=True
|
| 38 |
+
)
|
| 39 |
+
|
| 40 |
+
result = crew.kickoff()
|
| 41 |
+
return result
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def main():
|
| 45 |
+
st.set_page_config(page_title="Stock Market Analyzer", page_icon="📈")
|
| 46 |
+
|
| 47 |
+
st.title("Stock Market Analyzer")
|
| 48 |
+
|
| 49 |
+
# Project details
|
| 50 |
+
st.markdown("""
|
| 51 |
+
This Stock Market Analyzer uses CrewAI to generate detailed reports on companies.
|
| 52 |
+
It leverages multiple AI agents to perform comprehensive analysis:
|
| 53 |
+
- Research Analyst: Gathers general information about the company
|
| 54 |
+
- Financial Analyst: Analyzes financial data and SEC filings
|
| 55 |
+
- Investment Advisor: Provides investment recommendations
|
| 56 |
+
""")
|
| 57 |
+
|
| 58 |
+
# API Key inputs
|
| 59 |
+
gemini_api = st.sidebar.text_input("Enter your Gemini API Key:", type="password")
|
| 60 |
+
serper_api = st.sidebar.text_input("Enter your Serper API Key:", type="password")
|
| 61 |
+
sec_api = st.sidebar.text_input("Enter your SEC API Key:", type="password")
|
| 62 |
+
|
| 63 |
+
# Set environment variables
|
| 64 |
+
os.environ['GOOGLE_API_KEY'] = gemini_api
|
| 65 |
+
os.environ['SERPER_API_KEY'] = serper_api
|
| 66 |
+
os.environ['SEC_API_KEY'] = sec_api
|
| 67 |
+
|
| 68 |
+
# Company input
|
| 69 |
+
company = st.text_input("Enter the company name you want to analyze:")
|
| 70 |
+
|
| 71 |
+
if st.button("Analyze"):
|
| 72 |
+
if company and gemini_api and serper_api and sec_api:
|
| 73 |
+
with st.spinner("Analyzing... This may take a few minutes."):
|
| 74 |
+
financial_crew = FinancialCrew(company)
|
| 75 |
+
result = financial_crew.run()
|
| 76 |
+
|
| 77 |
+
st.success("Analysis complete!")
|
| 78 |
+
st.subheader("Analysis Report")
|
| 79 |
+
st.markdown(result)
|
| 80 |
+
else:
|
| 81 |
+
st.warning("Please enter all required information (API keys and company name).")
|
| 82 |
+
|
| 83 |
+
if __name__ == "__main__":
|
| 84 |
main()
|