Skip to content

Commit

Permalink
Preparing new version (#1845)
Browse files Browse the repository at this point in the history
* Preparing new version
  • Loading branch information
joaomdmoura authored Jan 4, 2025
1 parent 5188002 commit 7272fd1
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 59 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "crewai"
version = "0.86.0"
version = "0.95.0"
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."
readme = "README.md"
requires-python = ">=3.10,<3.13"
Expand Down
2 changes: 1 addition & 1 deletion src/crewai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
category=UserWarning,
module="pydantic.main",
)
__version__ = "0.86.0"
__version__ = "0.95.0"
__all__ = [
"Agent",
"Crew",
Expand Down
2 changes: 1 addition & 1 deletion src/crewai/cli/templates/crew/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "{{name}} using crewAI"
authors = [{ name = "Your Name", email = "[email protected]" }]
requires-python = ">=3.10,<3.13"
dependencies = [
"crewai[tools]>=0.86.0,<1.0.0"
"crewai[tools]>=0.95.0,<1.0.0"
]

[project.scripts]
Expand Down
2 changes: 1 addition & 1 deletion src/crewai/cli/templates/flow/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "{{name}} using crewAI"
authors = [{ name = "Your Name", email = "[email protected]" }]
requires-python = ">=3.10,<3.13"
dependencies = [
"crewai[tools]>=0.86.0,<1.0.0",
"crewai[tools]>=0.95.0,<1.0.0",
]

[project.scripts]
Expand Down
2 changes: 1 addition & 1 deletion src/crewai/cli/templates/tool/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Power up your crews with {{folder_name}}"
readme = "README.md"
requires-python = ">=3.10,<3.13"
dependencies = [
"crewai[tools]>=0.86.0"
"crewai[tools]>=0.95.0"
]

[tool.crewai]
Expand Down
52 changes: 28 additions & 24 deletions src/crewai/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import threading
import warnings
from contextlib import contextmanager
from importlib import resources
from typing import Any, Dict, List, Optional, Union

with warnings.catch_warnings():
Expand Down Expand Up @@ -78,6 +79,7 @@ def flush(self):
def suppress_warnings():
with warnings.catch_warnings():
warnings.filterwarnings("ignore")
warnings.filterwarnings("ignore", message="open_text is deprecated*", category=DeprecationWarning)

# Redirect stdout and stderr
old_stdout = sys.stdout
Expand Down Expand Up @@ -216,16 +218,17 @@ def get_context_window_size(self) -> int:
return self.context_window_size

def set_callbacks(self, callbacks: List[Any]):
callback_types = [type(callback) for callback in callbacks]
for callback in litellm.success_callback[:]:
if type(callback) in callback_types:
litellm.success_callback.remove(callback)
with suppress_warnings():
callback_types = [type(callback) for callback in callbacks]
for callback in litellm.success_callback[:]:
if type(callback) in callback_types:
litellm.success_callback.remove(callback)

for callback in litellm._async_success_callback[:]:
if type(callback) in callback_types:
litellm._async_success_callback.remove(callback)
for callback in litellm._async_success_callback[:]:
if type(callback) in callback_types:
litellm._async_success_callback.remove(callback)

litellm.callbacks = callbacks
litellm.callbacks = callbacks

def set_env_callbacks(self):
"""
Expand All @@ -246,19 +249,20 @@ def set_env_callbacks(self):
This will set `litellm.success_callback` to ["langfuse", "langsmith"] and
`litellm.failure_callback` to ["langfuse"].
"""
success_callbacks_str = os.environ.get("LITELLM_SUCCESS_CALLBACKS", "")
success_callbacks = []
if success_callbacks_str:
success_callbacks = [
callback.strip() for callback in success_callbacks_str.split(",")
]

failure_callbacks_str = os.environ.get("LITELLM_FAILURE_CALLBACKS", "")
failure_callbacks = []
if failure_callbacks_str:
failure_callbacks = [
callback.strip() for callback in failure_callbacks_str.split(",")
]

litellm.success_callback = success_callbacks
litellm.failure_callback = failure_callbacks
with suppress_warnings():
success_callbacks_str = os.environ.get("LITELLM_SUCCESS_CALLBACKS", "")
success_callbacks = []
if success_callbacks_str:
success_callbacks = [
callback.strip() for callback in success_callbacks_str.split(",")
]

failure_callbacks_str = os.environ.get("LITELLM_FAILURE_CALLBACKS", "")
failure_callbacks = []
if failure_callbacks_str:
failure_callbacks = [
callback.strip() for callback in failure_callbacks_str.split(",")
]

litellm.success_callback = success_callbacks
litellm.failure_callback = failure_callbacks
13 changes: 12 additions & 1 deletion src/crewai/tools/base_tool.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
import warnings
from abc import ABC, abstractmethod
from inspect import signature
from typing import Any, Callable, Type, get_args, get_origin

from pydantic import BaseModel, ConfigDict, Field, create_model, validator
from pydantic import (
BaseModel,
ConfigDict,
Field,
PydanticDeprecatedSince20,
create_model,
validator,
)
from pydantic import BaseModel as PydanticBaseModel

from crewai.tools.structured_tool import CrewStructuredTool

# Ignore all "PydanticDeprecatedSince20" warnings globally
warnings.filterwarnings("ignore", category=PydanticDeprecatedSince20)


class BaseTool(BaseModel, ABC):
class _ArgsSchemaPlaceholder(PydanticBaseModel):
Expand Down
8 changes: 4 additions & 4 deletions src/crewai/utilities/internal_instructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ def set_instructor(self):
import instructor
from litellm import completion

self._client = instructor.from_litellm(
completion,
mode=instructor.Mode.TOOLS,
)
self._client = instructor.from_litellm(
completion,
mode=instructor.Mode.TOOLS,
)

def to_json(self):
model = self.to_pydantic()
Expand Down
4 changes: 2 additions & 2 deletions tests/agents/agent_builder/base_agent_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from crewai.tools.base_tool import BaseTool


class TestAgent(BaseAgent):
class MockAgent(BaseAgent):
def execute_task(
self,
task: Any,
Expand All @@ -29,7 +29,7 @@ def get_output_converter(


def test_key():
agent = TestAgent(
agent = MockAgent(
role="test role",
goal="test goal",
backstory="test backstory",
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/deploy/test_deploy_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ def test_list_crews(self):
def test_get_crew_status(self):
mock_response = MagicMock()
mock_response.status_code = 200
mock_response.json.return_value = {"name": "TestCrew", "status": "active"}
mock_response.json.return_value = {"name": "InternalCrew", "status": "active"}
self.mock_client.crew_status_by_name.return_value = mock_response

with patch("sys.stdout", new=StringIO()) as fake_out:
self.deploy_command.get_crew_status()
self.assertIn("TestCrew", fake_out.getvalue())
self.assertIn("InternalCrew", fake_out.getvalue())
self.assertIn("active", fake_out.getvalue())

def test_get_crew_logs(self):
Expand Down
10 changes: 5 additions & 5 deletions tests/project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def custom_named_task(self):


@CrewBase
class TestCrew:
class InternalCrew:
agents_config = "config/agents.yaml"
tasks_config = "config/tasks.yaml"

Expand Down Expand Up @@ -84,7 +84,7 @@ def test_task_memoization():


def test_crew_memoization():
crew = TestCrew()
crew = InternalCrew()
first_call_result = crew.crew()
second_call_result = crew.crew()

Expand All @@ -107,15 +107,15 @@ def test_task_name():

@pytest.mark.vcr(filter_headers=["authorization"])
def test_before_kickoff_modification():
crew = TestCrew()
crew = InternalCrew()
inputs = {"topic": "LLMs"}
result = crew.crew().kickoff(inputs=inputs)
assert "bicycles" in result.raw, "Before kickoff function did not modify inputs"


@pytest.mark.vcr(filter_headers=["authorization"])
def test_after_kickoff_modification():
crew = TestCrew()
crew = InternalCrew()
# Assuming the crew execution returns a dict
result = crew.crew().kickoff({"topic": "LLMs"})

Expand All @@ -126,7 +126,7 @@ def test_after_kickoff_modification():

@pytest.mark.vcr(filter_headers=["authorization"])
def test_before_kickoff_with_none_input():
crew = TestCrew()
crew = InternalCrew()
crew.crew().kickoff(None)
# Test should pass without raising exceptions

Expand Down
4 changes: 2 additions & 2 deletions tests/test_manager_llm_delegation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from crewai.tools.agent_tools.base_agent_tools import BaseAgentTool


class TestAgentTool(BaseAgentTool):
class InternalAgentTool(BaseAgentTool):
"""Concrete implementation of BaseAgentTool for testing."""

def _run(self, *args, **kwargs):
Expand Down Expand Up @@ -39,7 +39,7 @@ def test_agent_tool_role_matching(role_name, should_match):
)

# Create test agent tool
agent_tool = TestAgentTool(
agent_tool = InternalAgentTool(
name="test_tool", description="Test tool", agents=[test_agent]
)

Expand Down
8 changes: 4 additions & 4 deletions tests/tools/test_base_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def my_tool(question: str) -> str:
my_tool.description
== "Tool Name: Name of my tool\nTool Arguments: {'question': {'description': None, 'type': 'str'}}\nTool Description: Clear description for what this tool is useful for, your agent will need this information to use it."
)
assert my_tool.args_schema.schema()["properties"] == {
assert my_tool.args_schema.model_json_schema()["properties"] == {
"question": {"title": "Question", "type": "string"}
}
assert (
Expand All @@ -29,7 +29,7 @@ def my_tool(question: str) -> str:
converted_tool.description
== "Tool Name: Name of my tool\nTool Arguments: {'question': {'description': None, 'type': 'str'}}\nTool Description: Clear description for what this tool is useful for, your agent will need this information to use it."
)
assert converted_tool.args_schema.schema()["properties"] == {
assert converted_tool.args_schema.model_json_schema()["properties"] == {
"question": {"title": "Question", "type": "string"}
}
assert (
Expand All @@ -54,7 +54,7 @@ def _run(self, question: str) -> str:
my_tool.description
== "Tool Name: Name of my tool\nTool Arguments: {'question': {'description': None, 'type': 'str'}}\nTool Description: Clear description for what this tool is useful for, your agent will need this information to use it."
)
assert my_tool.args_schema.schema()["properties"] == {
assert my_tool.args_schema.model_json_schema()["properties"] == {
"question": {"title": "Question", "type": "string"}
}
assert my_tool.run("What is the meaning of life?") == "What is the meaning of life?"
Expand All @@ -66,7 +66,7 @@ def _run(self, question: str) -> str:
converted_tool.description
== "Tool Name: Name of my tool\nTool Arguments: {'question': {'description': None, 'type': 'str'}}\nTool Description: Clear description for what this tool is useful for, your agent will need this information to use it."
)
assert converted_tool.args_schema.schema()["properties"] == {
assert converted_tool.args_schema.model_json_schema()["properties"] == {
"question": {"title": "Question", "type": "string"}
}
assert (
Expand Down
2 changes: 1 addition & 1 deletion tests/tools/test_structured_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TestSchema(BaseModel):
return TestSchema


class TestCrewStructuredTool:
class InternalCrewStructuredTool:
def test_initialization(self, basic_function, schema_class):
"""Test basic initialization of CrewStructuredTool"""
tool = CrewStructuredTool(
Expand Down
2 changes: 1 addition & 1 deletion tests/utilities/evaluators/test_crew_evaluator_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)


class TestCrewEvaluator:
class InternalCrewEvaluator:
@pytest.fixture
def crew_planner(self):
agent = Agent(role="Agent 1", goal="Goal 1", backstory="Backstory 1")
Expand Down
12 changes: 6 additions & 6 deletions tests/utilities/test_planning_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
)


class TestCrewPlanner:
class InternalCrewPlanner:
@pytest.fixture
def crew_planner(self):
tasks = [
Expand Down Expand Up @@ -115,13 +115,13 @@ class MockTool(BaseTool):
def __init__(self, name: str, description: str):
tool_data = {"name": name, "description": description}
super().__init__(**tool_data)

def __str__(self):
return self.name

def __repr__(self):
return self.name

def to_structured_tool(self):
return self

Expand Down Expand Up @@ -149,11 +149,11 @@ def _generate_description(self) -> str:
]
)
)

# Create planner with the new task
planner = CrewPlanner([task], None)
tasks_summary = planner._create_tasks_summary()

# Verify task summary content
assert isinstance(tasks_summary, str)
assert task.description in tasks_summary
Expand Down
2 changes: 1 addition & 1 deletion tests/utilities/test_training_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from crewai.utilities.training_handler import CrewTrainingHandler


class TestCrewTrainingHandler(unittest.TestCase):
class InternalCrewTrainingHandler(unittest.TestCase):
def setUp(self):
self.handler = CrewTrainingHandler("trained_data.pkl")

Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7272fd1

Please sign in to comment.