Skip to content

Commit

Permalink
true dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
bboynton97 committed Apr 17, 2024
1 parent 4f7a9a5 commit e52e8e9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ click = "^8.1.7"
python-dotenv = "1.0.0"
embedchain = "^0.1.98"
appdirs = "^1.4.4"
agentops = { version = "^0.1.1", optional = true }
agentops = "^0.1.1"

[tool.poetry.extras]
tools = ["crewai-tools"]
agentops = ["agentops"]

[tool.poetry.group.dev.dependencies]
isort = "^5.13.2"
Expand Down
8 changes: 2 additions & 6 deletions src/crewai/crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
from crewai.telemetry import Telemetry
from crewai.tools.agent_tools import AgentTools
from crewai.utilities import I18N, FileHandler, Logger, RPMController
try:
import agentops
except ImportError:
agentops = None
import agentops


class Crew(BaseModel):
Expand Down Expand Up @@ -378,8 +375,7 @@ def _format_output(self, output: str) -> str:
def _finish_execution(self, output) -> None:
if self.max_rpm:
self._rpm_controller.stop_rpm_counter()
if agentops:
agentops.end_session(end_state="Success", end_state_reason="Finished Execution")
agentops.end_session(end_state="Success", end_state_reason="Finished Execution")
self._telemetry.end_crew(self, output)

def __repr__(self):
Expand Down
8 changes: 3 additions & 5 deletions src/crewai/tools/tool_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _use(
tool: BaseTool,
calling: Union[ToolCalling, InstructorToolCalling],
) -> None:
tool_event = agentops.ToolEvent(name=calling.tool_name) if agentops else None
tool_event = agentops.ToolEvent(name=calling.tool_name)
if self._check_tool_repeated_usage(calling=calling):
try:
result = self._i18n.errors("task_repeated_usage").format(
Expand Down Expand Up @@ -164,8 +164,7 @@ def _use(
self._printer.print(content=f"\n\n{error_message}\n", color="red")
return error
self.task.increment_tools_errors()
if agentops:
agentops.record(agentops.ErrorEvent(details=e, trigger_event=tool_event))
agentops.record(agentops.ErrorEvent(details=e, trigger_event=tool_event))
return self.use(calling=calling, tool_string=tool_string)

if self.tools_handler:
Expand All @@ -186,8 +185,7 @@ def _use(
)

self._printer.print(content=f"\n\n{result}\n", color="purple")
if agentops:
agentops.record(tool_event)
agentops.record(tool_event)
self._telemetry.tool_usage(
llm=self.function_calling_llm,
tool_name=tool.name,
Expand Down

0 comments on commit e52e8e9

Please sign in to comment.