Skip to content

Commit

Permalink
chore: debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
thompsonson committed Jul 18, 2024
1 parent 1903358 commit 233e8ea
Show file tree
Hide file tree
Showing 6 changed files with 591 additions and 440 deletions.
19 changes: 19 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Remove all files in the 'dist' directory
rm -f dist/*

# Remove all files in the '../ctim/crewAI/dist' directory
rm -f ../ctim/crewAI/dist/*

# Build the project using Poetry
poetry build

# Copy all files from the 'dist' directory to '../ctim/crewAI/dist'
cp -r dist/* ../ctim/crewAI/dist/

cd ../ctim/

make build && make up

cd ../crewAI
976 changes: 537 additions & 439 deletions poetry.lock

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions src/crewai/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ class Agent(BaseAgent):
def __init__(__pydantic_self__, **data):
config = data.pop("config", {})
super().__init__(**config, **data)
print(
f"[CrewAI.Agent.__init__]: Agent: {__pydantic_self__.role} has been init with ToolsHandler: {__pydantic_self__.tools_handler}"
)
print(
f"[CrewAI.Agent.__init__]: Agent: {__pydantic_self__.role} has been init with ToolsHandler: {__pydantic_self__.callbacks}"
)

@model_validator(mode="after")
def set_agent_executor(self) -> "Agent":
Expand All @@ -104,6 +110,9 @@ def set_agent_executor(self) -> "Agent":
if not self.agent_executor:
if not self.cache_handler:
self.cache_handler = CacheHandler()
print(
f"[CrewAI.Agent.set_agent_executor]: calling set_cache_handler for agent {self}"
)
self.set_cache_handler(self.cache_handler)
return self

Expand All @@ -126,6 +135,11 @@ def execute_task(
if self.tools_handler:
# type: ignore # Incompatible types in assignment (expression has type "dict[Never, Never]", variable has type "ToolCalling")
self.tools_handler.last_used_tool = {}
print(
f"[CrewAI.Agent.execute_task]: task has a tools_handler: {self.tools_handler}"
)
else:
print("[CrewAI.Agent.execute_task]: task DOES NOT HAVE a tools_handler")

task_prompt = task.prompt()

Expand Down Expand Up @@ -246,6 +260,12 @@ def create_agent_executor(self, tools=None) -> None:
bind = self.llm.bind(stop=stop_words)

inner_agent = agent_args | execution_prompt | bind | CrewAgentParser(agent=self)

print(
f"[CrewAI.Agent.create_agent_executor]: setting the agent_executor for agent {self}"
)
callbacks = executor_args.get("callbacks", "No callbacks found")
print(f"[CrewAI.Agent.create_agent_executor]: callbacks are: {callbacks}")
self.agent_executor = CrewAgentExecutor(
agent=RunnableAgent(runnable=inner_agent), **executor_args
)
Expand Down
9 changes: 9 additions & 0 deletions src/crewai/agents/agent_builder/base_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,16 @@ def set_cache_handler(self, cache_handler: CacheHandler) -> None:
cache_handler: An instance of the CacheHandler class.
"""
if not self.tools_handler:
print(
"[CrewAI.BaseAgent.set_cache_handler]: Using the default ToolsHandler"
)
print(
f"[CrewAI.BaseAgent.set_cache_handler]: default ToolsHandler is being used by agent: {self}"
)
self.tools_handler = ToolsHandler()
print(
f"[CrewAI.BaseAgent.set_cache_handler]: ToolsHandler = {self.tools_handler}"
)
if self.cache:
self.cache_handler = cache_handler
self.tools_handler.cache = cache_handler
Expand Down
2 changes: 1 addition & 1 deletion src/crewai/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def _execute(self, agent, task, context, tools):
)
exported_output = self._export_output(result)

# type: the responses are usually str but need to figuire out a more elegant solution here
# the responses are usually str but need to figuire out a more elegant solution here
self.output = TaskOutput(
description=self.description,
exported_output=exported_output,
Expand Down
5 changes: 5 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# conftest.py
from dotenv import load_dotenv

import os

os.environ["OTEL_SDK_DISABLED"] = "true"


load_result = load_dotenv(override=True)

0 comments on commit 233e8ea

Please sign in to comment.