Spaces:
Sleeping
Sleeping
Commit
·
a264ad8
1
Parent(s):
9244847
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,65 +7,65 @@ from crewai import Agent, Task, Crew, Process
|
|
| 7 |
|
| 8 |
os.environ["OPENAI_API_KEY"] = "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"
|
| 9 |
|
| 10 |
-
from crewai import Agent, Task, Crew, Process
|
| 11 |
|
| 12 |
# Crew Bot: https://chat.openai.com/g/g-qqTuUWsBY-crewai-assistant
|
| 13 |
|
| 14 |
-
|
| 15 |
from stock_analysis_agents import StockAnalysisAgents
|
| 16 |
from stock_analysis_tasks import StockAnalysisTasks
|
|
|
|
| 17 |
|
| 18 |
load_dotenv()
|
| 19 |
|
| 20 |
class FinancialCrew:
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
return result
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
if __name__ == "__main__":
|
| 56 |
-
|
| 57 |
-
print('-------------------------------')
|
| 58 |
-
company = input(
|
| 59 |
-
dedent("""
|
| 60 |
-
What is the company you want to analyze?
|
| 61 |
-
"""))
|
| 62 |
-
|
| 63 |
-
financial_crew = FinancialCrew(company)
|
| 64 |
-
result = financial_crew.run()
|
| 65 |
-
print("\n\n########################")
|
| 66 |
-
print("## Here is the Report")
|
| 67 |
-
print("########################\n")
|
| 68 |
-
print(result)
|
| 69 |
|
| 70 |
|
| 71 |
|
|
|
|
| 7 |
|
| 8 |
os.environ["OPENAI_API_KEY"] = "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"
|
| 9 |
|
|
|
|
| 10 |
|
| 11 |
# Crew Bot: https://chat.openai.com/g/g-qqTuUWsBY-crewai-assistant
|
| 12 |
|
|
|
|
| 13 |
from stock_analysis_agents import StockAnalysisAgents
|
| 14 |
from stock_analysis_tasks import StockAnalysisTasks
|
| 15 |
+
from dotenv import load_dotenv
|
| 16 |
|
| 17 |
load_dotenv()
|
| 18 |
|
| 19 |
class FinancialCrew:
|
| 20 |
+
def __init__(self, company):
|
| 21 |
+
self.company = company
|
| 22 |
+
|
| 23 |
+
def run(self):
|
| 24 |
+
agents = StockAnalysisAgents()
|
| 25 |
+
tasks = StockAnalysisTasks()
|
| 26 |
+
|
| 27 |
+
research_analyst_agent = agents.research_analyst()
|
| 28 |
+
financial_analyst_agent = agents.financial_analyst()
|
| 29 |
+
investment_advisor_agent = agents.investment_advisor()
|
| 30 |
+
|
| 31 |
+
research_task = tasks.research(research_analyst_agent, self.company)
|
| 32 |
+
financial_task = tasks.financial_analysis(financial_analyst_agent)
|
| 33 |
+
filings_task = tasks.filings_analysis(financial_analyst_agent)
|
| 34 |
+
recommend_task = tasks.recommend(investment_advisor_agent)
|
| 35 |
+
|
| 36 |
+
crew = Crew(
|
| 37 |
+
agents=[
|
| 38 |
+
research_analyst_agent,
|
| 39 |
+
financial_analyst_agent,
|
| 40 |
+
investment_advisor_agent
|
| 41 |
+
],
|
| 42 |
+
tasks=[
|
| 43 |
+
research_task,
|
| 44 |
+
financial_task,
|
| 45 |
+
filings_task,
|
| 46 |
+
recommend_task
|
| 47 |
+
],
|
| 48 |
+
verbose=True
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
result = crew.kickoff()
|
| 52 |
+
return result
|
| 53 |
+
|
| 54 |
+
def run_financial_analysis(company_name):
|
| 55 |
+
financial_crew = FinancialCrew(company_name)
|
| 56 |
+
result = financial_crew.run()
|
| 57 |
return result
|
| 58 |
|
| 59 |
+
iface = gr.Interface(
|
| 60 |
+
fn=run_financial_analysis,
|
| 61 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter Company Name Here"),
|
| 62 |
+
outputs="text",
|
| 63 |
+
title="Financial Analysis Crew",
|
| 64 |
+
description="Enter a company name to get financial analysis."
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
if __name__ == "__main__":
|
| 68 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
|
| 71 |
|