Skip to content

Commit

Permalink
Making config optional with default value as it's WIP and Adding new …
Browse files Browse the repository at this point in the history
…treatment for wrong agent tool calls
  • Loading branch information
joaomdmoura committed Dec 5, 2023
1 parent 2ff9ad8 commit 9be65e0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
5 changes: 4 additions & 1 deletion crewai/crew.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class Crew(BaseModel):
Class that represents a group of agents, how they should work together and
their tasks.
"""
config: Optional[Json] = Field(description="Configuration of the crew.")
tasks: Optional[List[Task]] = Field(description="List of tasks")
agents: Optional[List[Agent]] = Field(description="List of agents in this crew.")
process: Process = Field(
Expand All @@ -23,6 +22,10 @@ class Crew(BaseModel):
description="Verbose mode for the Agent Execution",
default=False
)
config: Optional[Json] = Field(
description="Configuration of the crew.",
default=None
)

@root_validator(pre=True)
def check_config(_cls, values):
Expand Down
8 changes: 6 additions & 2 deletions crewai/tools/agent_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ def ask_question(self, command):

def __execute(self, command):
"""Execute the command."""
agent, task, information = command.split("|")
try:
agent, task, information = command.split("|")
except ValueError:
return "Error executing tool. Missing exact 3 pipe (|) separated values."

if not agent or not task or not information:
return "Error executing tool. Missing 3 pipe (|) separated values."
return "Error executing tool. Missing exact 3 pipe (|) separated values."

agent = [available_agent for available_agent in self.agents if available_agent.role == agent]

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[tool.poetry]
name = "crewai"
version = "0.1.3"
version = "0.1.5"
description = "Cutting-edge framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks."
authors = ["Joao Moura <[email protected]>"]
readme = "README.md"
Expand Down
7 changes: 7 additions & 0 deletions tests/agent_tools/agent_tools_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ def test_ask_question():

assert result == "As a researcher, my feelings towards AI Agents are neutral. I neither love nor hate them. I study and analyze them objectively to understand their potential, capabilities, and limitations. While I appreciate the technological advancement they represent, my job is to approach them from an analytical and scientific perspective."

def test_delegate_work_with_wrong_input():
result = tools.ask_question(
command="writer|share your take on AI Agents"
)

assert result == "Error executing tool. Missing exact 3 pipe (|) separated values."

def test_delegate_work_to_wrong_agent():
result = tools.ask_question(
command="writer|share your take on AI Agents|I heard you hate them"
Expand Down

0 comments on commit 9be65e0

Please sign in to comment.