Revert "true dependency"

This reverts commit e52e8e9568.
This commit is contained in:
Braelyn Boynton
2024-04-19 19:01:52 -07:00
parent 216cc832dc
commit 4d1b460b80
3 changed files with 13 additions and 6 deletions

View File

@@ -28,10 +28,11 @@ click = "^8.1.7"
python-dotenv = "1.0.0"
embedchain = "^0.1.98"
appdirs = "^1.4.4"
agentops = "^0.1.1"
agentops = { version = "^0.1.1", optional = true }
[tool.poetry.extras]
tools = ["crewai-tools"]
agentops = ["agentops"]
[tool.poetry.group.dev.dependencies]
isort = "^5.13.2"

View File

@@ -26,7 +26,10 @@ from crewai.task import Task
from crewai.telemetry import Telemetry
from crewai.tools.agent_tools import AgentTools
from crewai.utilities import I18N, FileHandler, Logger, RPMController
import agentops
try:
import agentops
except ImportError:
agentops = None
class Crew(BaseModel):
@@ -376,7 +379,8 @@ class Crew(BaseModel):
def _finish_execution(self, output) -> None:
if self.max_rpm:
self._rpm_controller.stop_rpm_counter()
agentops.end_session(end_state="Success", end_state_reason="Finished Execution")
if agentops:
agentops.end_session(end_state="Success", end_state_reason="Finished Execution")
self._telemetry.end_crew(self, output)
def __repr__(self):

View File

@@ -97,7 +97,7 @@ class ToolUsage:
tool: BaseTool,
calling: Union[ToolCalling, InstructorToolCalling],
) -> None:
tool_event = agentops.ToolEvent(name=calling.tool_name)
tool_event = agentops.ToolEvent(name=calling.tool_name) if agentops else None
if self._check_tool_repeated_usage(calling=calling):
try:
result = self._i18n.errors("task_repeated_usage").format(
@@ -161,7 +161,8 @@ class ToolUsage:
self._printer.print(content=f"\n\n{error_message}\n", color="red")
return error
self.task.increment_tools_errors()
agentops.record(agentops.ErrorEvent(details=e, trigger_event=tool_event))
if agentops:
agentops.record(agentops.ErrorEvent(details=e, trigger_event=tool_event))
return self.use(calling=calling, tool_string=tool_string)
if self.tools_handler:
@@ -182,7 +183,8 @@ class ToolUsage:
)
self._printer.print(content=f"\n\n{result}\n", color="purple")
agentops.record(tool_event)
if agentops:
agentops.record(tool_event)
self._telemetry.tool_usage(
llm=self.function_calling_llm,
tool_name=tool.name,