Skip to content

Commit

Permalink
Merge pull request #166 from adityahiran/main
Browse files Browse the repository at this point in the history
fix: Updated stock_analysis to make it work again and tested with llama3.1
  • Loading branch information
theCyberTech authored Oct 3, 2024
2 parents d60bfc5 + 2249415 commit c713873
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion stock_analysis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ not to, and by doing so it will cost you money.*

- **Configure Environment**: Copy ``.env.example` and set up the environment variables for [Browseless](https://www.browserless.io/), [Serper](https://serper.dev/), [SEC-API](https://sec-api.io) and [OpenAI](https://platform.openai.com/api-keys)
- **Install Dependencies**: Run `poetry install --no-root`.
- **Execute the Script**: Run `python main.py` and input your idea.
- **Execute the Script**: Run `poetry run python3 main.py`. (Note: execute from the directory containing main.pyy)

## Details & Explanation
- **Running the Script**: Execute `python main.py`` and input the company to be analyzed when prompted. The script will leverage the CrewAI framework to analyze the company and generate a detailed report.
Expand Down
1 change: 1 addition & 0 deletions stock_analysis/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ python = ">=3.12,<=3.13"
crewai = {extras = ["tools"], version = "^0.41.1"}
python-dotenv = "^1.0.1"
html2text = "^2024.2.26"
sec-api = "^1.0.20"

[tool.poetry.scripts]
stock_analysis = "stock_analysis.main:run"
Expand Down
16 changes: 13 additions & 3 deletions stock_analysis/src/stock_analysis/crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
from crewai import Agent, Crew, Process, Task
from crewai.project import CrewBase, agent, crew, task

from stock_analysis.tools.calculator_tool import CalculatorTool
from stock_analysis.tools.sec_tools import SEC10KTool, SEC10QTool
from tools.calculator_tool import CalculatorTool
from tools.sec_tools import SEC10KTool, SEC10QTool

from crewai_tools import WebsiteSearchTool, ScrapeWebsiteTool, TXTSearchTool

from dotenv import load_dotenv
load_dotenv()

from langchain.llms import Ollama
llm = Ollama(model="llama3.1")

@CrewBase
class StockAnalysisCrew:
agents_config = 'config/agents.yaml'
Expand All @@ -17,6 +23,7 @@ def financial_agent(self) -> Agent:
return Agent(
config=self.agents_config['financial_analyst'],
verbose=True,
llm=llm,
tools=[
ScrapeWebsiteTool(),
WebsiteSearchTool(),
Expand All @@ -39,6 +46,7 @@ def research_analyst_agent(self) -> Agent:
return Agent(
config=self.agents_config['research_analyst'],
verbose=True,
llm=llm,
tools=[
ScrapeWebsiteTool(),
# WebsiteSearchTool(),
Expand All @@ -59,6 +67,7 @@ def financial_analyst_agent(self) -> Agent:
return Agent(
config=self.agents_config['financial_analyst'],
verbose=True,
llm=llm,
tools=[
ScrapeWebsiteTool(),
WebsiteSearchTool(),
Expand Down Expand Up @@ -87,6 +96,7 @@ def investment_advisor_agent(self) -> Agent:
return Agent(
config=self.agents_config['investment_advisor'],
verbose=True,
llm=llm,
tools=[
ScrapeWebsiteTool(),
WebsiteSearchTool(),
Expand All @@ -109,5 +119,5 @@ def crew(self) -> Crew:
agents=self.agents,
tasks=self.tasks,
process=Process.sequential,
verbose=2,
verbose=True,
)
17 changes: 12 additions & 5 deletions stock_analysis/src/stock_analysis/main.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import sys
from stock_analysis.crew import StockAnalysisCrew
from crew import StockAnalysisCrew

def run():
inputs = {
'query': 'What is the best running shoe for beginner',
'query': 'What is the company you want to analyze?',
'company_stock': 'AMZN',
}
StockAnalysisCrew().crew().kickoff(inputs=inputs)


return StockAnalysisCrew().crew().kickoff(inputs=inputs)

def train():
"""
Expand All @@ -23,3 +21,12 @@ def train():

except Exception as e:
raise Exception(f"An error occurred while training the crew: {e}")

if __name__ == "__main__":
print("## Welcome to Stock Analysis Crew")
print('-------------------------------')
result = run()
print("\n\n########################")
print("## Here is the Report")
print("########################\n")
print(result)

0 comments on commit c713873

Please sign in to comment.