mirror of
https://github.com/crewAIInc/crewAI.git
synced 2025-12-18 05:18:31 +00:00
@@ -28,10 +28,11 @@ click = "^8.1.7"
|
|||||||
python-dotenv = "1.0.0"
|
python-dotenv = "1.0.0"
|
||||||
embedchain = "^0.1.98"
|
embedchain = "^0.1.98"
|
||||||
appdirs = "^1.4.4"
|
appdirs = "^1.4.4"
|
||||||
agentops = "^0.1.1"
|
agentops = { version = "^0.1.1", optional = true }
|
||||||
|
|
||||||
[tool.poetry.extras]
|
[tool.poetry.extras]
|
||||||
tools = ["crewai-tools"]
|
tools = ["crewai-tools"]
|
||||||
|
agentops = ["agentops"]
|
||||||
|
|
||||||
[tool.poetry.group.dev.dependencies]
|
[tool.poetry.group.dev.dependencies]
|
||||||
isort = "^5.13.2"
|
isort = "^5.13.2"
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ from crewai.task import Task
|
|||||||
from crewai.telemetry import Telemetry
|
from crewai.telemetry import Telemetry
|
||||||
from crewai.tools.agent_tools import AgentTools
|
from crewai.tools.agent_tools import AgentTools
|
||||||
from crewai.utilities import I18N, FileHandler, Logger, RPMController
|
from crewai.utilities import I18N, FileHandler, Logger, RPMController
|
||||||
import agentops
|
try:
|
||||||
|
import agentops
|
||||||
|
except ImportError:
|
||||||
|
agentops = None
|
||||||
|
|
||||||
|
|
||||||
class Crew(BaseModel):
|
class Crew(BaseModel):
|
||||||
@@ -376,6 +379,7 @@ class Crew(BaseModel):
|
|||||||
def _finish_execution(self, output) -> None:
|
def _finish_execution(self, output) -> None:
|
||||||
if self.max_rpm:
|
if self.max_rpm:
|
||||||
self._rpm_controller.stop_rpm_counter()
|
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)
|
self._telemetry.end_crew(self, output)
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class ToolUsage:
|
|||||||
tool: BaseTool,
|
tool: BaseTool,
|
||||||
calling: Union[ToolCalling, InstructorToolCalling],
|
calling: Union[ToolCalling, InstructorToolCalling],
|
||||||
) -> None:
|
) -> 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):
|
if self._check_tool_repeated_usage(calling=calling):
|
||||||
try:
|
try:
|
||||||
result = self._i18n.errors("task_repeated_usage").format(
|
result = self._i18n.errors("task_repeated_usage").format(
|
||||||
@@ -161,6 +161,7 @@ class ToolUsage:
|
|||||||
self._printer.print(content=f"\n\n{error_message}\n", color="red")
|
self._printer.print(content=f"\n\n{error_message}\n", color="red")
|
||||||
return error
|
return error
|
||||||
self.task.increment_tools_errors()
|
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)
|
return self.use(calling=calling, tool_string=tool_string)
|
||||||
|
|
||||||
@@ -182,6 +183,7 @@ class ToolUsage:
|
|||||||
)
|
)
|
||||||
|
|
||||||
self._printer.print(content=f"\n\n{result}\n", color="purple")
|
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(
|
self._telemetry.tool_usage(
|
||||||
llm=self.function_calling_llm,
|
llm=self.function_calling_llm,
|
||||||
|
|||||||
Reference in New Issue
Block a user