diff --git a/stock_analysis/stock_analysis_agents.py b/stock_analysis/stock_analysis_agents.py index b7ba5b9e2..3842b1446 100644 --- a/stock_analysis/stock_analysis_agents.py +++ b/stock_analysis/stock_analysis_agents.py @@ -1,4 +1,5 @@ from crewai import Agent +from crewai_tools import ScrapeWebsiteTool from tools.browser_tools import BrowserTools from tools.calculator_tools import CalculatorTools @@ -6,8 +7,13 @@ from tools.sec_tools import SECTools from langchain.tools.yahoo_finance_news import YahooFinanceNewsTool +from langchain.chat_models import ChatOpenAI class StockAnalysisAgents(): + llm_chatgpt3 = ChatOpenAI(model='gpt-3.5-turbo') + llm_chatgpt4 = ChatOpenAI(model='gpt-4') + scrape_and_summarize_website = ScrapeWebsiteTool() + def financial_analyst(self): return Agent( role='The Best Financial Analyst', @@ -17,8 +23,9 @@ def financial_analyst(self): lots of expertise in stock market analysis and investment strategies that is working for a super important customer.""", verbose=True, + llm=self.llm_chatgpt3, tools=[ - BrowserTools.scrape_and_summarize_website, + self.scrape_and_summarize_website, SearchTools.search_internet, CalculatorTools.calculate, SECTools.search_10q, @@ -36,8 +43,9 @@ def research_analyst(self): and market sentiments. Now you're working on a super important customer""", verbose=True, + llm=self.llm_chatgpt3, tools=[ - BrowserTools.scrape_and_summarize_website, + self.scrape_and_summarize_website, SearchTools.search_internet, SearchTools.search_news, YahooFinanceNewsTool(), @@ -56,8 +64,9 @@ def investment_advisor(self): strategic investment advice. You are now working for a super important customer you need to impress.""", verbose=True, + llm=self.llm_chatgpt3, tools=[ - BrowserTools.scrape_and_summarize_website, + self.scrape_and_summarize_website, SearchTools.search_internet, SearchTools.search_news, CalculatorTools.calculate, diff --git a/stock_analysis/stock_analysis_tasks.py b/stock_analysis/stock_analysis_tasks.py index 86dd0d4c8..de6711cc7 100644 --- a/stock_analysis/stock_analysis_tasks.py +++ b/stock_analysis/stock_analysis_tasks.py @@ -11,11 +11,6 @@ def research(self, agent, company): sentiments, and analysts' opinions. Also include upcoming events like earnings and others. - Your final answer MUST be a report that includes a - comprehensive summary of the latest news, any notable - shifts in market sentiment, and potential impacts on - the stock. - Also make sure to return the stock ticker. {self.__tip_section()} @@ -23,6 +18,13 @@ def research(self, agent, company): Selected company by the customer: {company} """), + expected_output = dedent(f""" + Your final answer MUST be a report that includes a + comprehensive summary of the latest news, any notable + shifts in market sentiment, and potential impacts on + the stock. + Also make sure to return the stock ticker. + """), agent=agent ) @@ -35,15 +37,17 @@ def financial_analysis(self, agent): debt-to-equity ratio. Also, analyze the stock's performance in comparison to its industry peers and overall market trends. - + {self.__tip_section()} + """), + expected_output = dedent(f""" Your final report MUST expand on the summary provided but now including a clear assessment of the stock's financial standing, its strengths and weaknesses, and how it fares against its competitors in the current - market scenario.{self.__tip_section()} + market scenario. Make sure to use the most recent data possible. - """), + """), agent=agent ) @@ -56,13 +60,14 @@ def filings_analysis(self, agent): and any disclosed risks. Extract relevant data and insights that could influence the stock's future performance. - + {self.__tip_section()} + """), + expected_output = dedent(f""" Your final answer must be an expanded report that now also highlights significant findings from these filings, including any red flags or positive indicators for your customer. - {self.__tip_section()} - """), + """), agent=agent ) @@ -80,12 +85,15 @@ def recommend(self, agent): Make sure to include a section that shows insider trading activity, and upcoming events like earnings. + + {self.__tip_section()} + """), + expected_output = dedent(f""" Your final answer MUST be a recommendation for your customer. It should be a full super detailed report, providing a clear investment stance and strategy with supporting evidence. Make it pretty and well formatted for your customer. - {self.__tip_section()} - """), + """), agent=agent )