Skip to content

Commit

Permalink
Remove crewai-tools dependency (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
evangriffiths authored May 10, 2024
1 parent 95b3f2f commit 01aa75a
Show file tree
Hide file tree
Showing 7 changed files with 267 additions and 265 deletions.
4 changes: 0 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,4 @@ COPY prediction_market_agent ./prediction_market_agent

ENV PYTHONPATH=/app

# TODO: This is a hotfix, because we are unable to lock this version with mech-client, remove this ASAP when PRs are merged into Valory and update pyproject in PMAT.
# This also works locally, after doing `poetry install` just go to `poetry shell` and run `pip install crewai["tools"]==0.22.5`.
RUN pip install 'crewai[tools]'==0.22.5

CMD ["bash", "-c", "python prediction_market_agent/run_agent.py ${runnable_agent_name} ${market_type}"]
471 changes: 256 additions & 215 deletions poetry.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import typer
from functions import RememberPastLearnings
from microchain import LLM, Agent, Engine, OpenAIChatGenerator
from microchain.functions import Reasoning, Stop
from prediction_market_agent_tooling.markets.markets import MarketType

from prediction_market_agent.agents.microchain_agent.functions import (
MARKET_FUNCTIONS,
MISC_FUNCTIONS,
RememberPastLearnings,
)
from prediction_market_agent.agents.microchain_agent.memory import LongTermMemory
from prediction_market_agent.agents.microchain_agent.omen_functions import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import typing as t

from crewai import Agent, Crew, Process, Task
from langchain.tools.tavily_search import TavilySearchResults
from langchain.utilities.tavily_search import TavilySearchAPIWrapper
from langchain_core.language_models import BaseChatModel
from langchain_core.pydantic_v1 import SecretStr
from langchain_openai import ChatOpenAI
from openai import APIError
from prediction_market_agent_tooling.deploy.agent import Answer
Expand All @@ -21,7 +24,6 @@
RESEARCH_OUTCOME_PROMPT,
RESEARCH_OUTCOME_WITH_PREVIOUS_OUTPUTS_PROMPT,
)
from prediction_market_agent.tools.custom_crewai_tools import TavilyDevTool
from prediction_market_agent.utils import APIKeys


Expand Down Expand Up @@ -57,8 +59,10 @@ def _get_predictor(self) -> Agent:
llm=self._build_llm(),
)

def _build_tavily_search(self) -> TavilyDevTool:
return TavilyDevTool()
def _build_tavily_search(self) -> TavilySearchResults:
api_key = SecretStr(APIKeys().tavily_api_key.get_secret_value())
api_wrapper = TavilySearchAPIWrapper(tavily_api_key=api_key)
return TavilySearchResults(api_wrapper=api_wrapper)

def _build_llm(self) -> BaseChatModel:
keys = APIKeys()
Expand Down
38 changes: 0 additions & 38 deletions prediction_market_agent/tools/custom_crewai_tools.py

This file was deleted.

2 changes: 1 addition & 1 deletion prediction_market_agent/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def openai_api_key(self) -> SecretStr:
@property
def tavily_api_key(self) -> SecretStr:
return check_not_none(
self.TAVILY_API_KEY, "OPENAI_API_KEY missing in the environment."
self.TAVILY_API_KEY, "TAVILY_API_KEY missing in the environment."
)


Expand Down
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ google-search-results = "*"
pytest = "*"
llama-index = "~0.9.0"
duckduckgo-search = "*"
crewai = {extras = ["tools"], version = "^0.11.0"}
crewai = "^0.22.2"
# metagpt = "*" # Commented out because requires super old version of langchain, and conflicts with crewai.
replicate = "*"
typer = "^0.9.0"
Expand Down Expand Up @@ -53,9 +53,8 @@ pypdf2 = "^3.0.1" # TODO remove with https://github.com/gnosis/prediction-market
faiss-cpu = "^1.8.0" # TODO remove with https://github.com/gnosis/prediction-market-agent/issues/97
psycopg2-binary = "^2.9.9"
sqlmodel = "^0.0.18"

farcaster = "^0.7.11"
mech-client = "^0.2.13"
mech-client = { git = "https://github.com/valory-xyz/mech-client.git", rev = "4a43da7ba50e5c271f8c763a3f1c7ae1cc9dfe0e" } # TODO update to 0.2.14 when available
streamlit-extras = "^0.4.2"

[build-system]
Expand Down

0 comments on commit 01aa75a

Please sign in to comment.