mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 00:58:30 +00:00
fix: tests
This commit is contained in:
@@ -1,21 +1,21 @@
|
|||||||
"""Test Agent creation and execution basic functionality."""
|
"""Test Agent creation and execution basic functionality."""
|
||||||
|
|
||||||
|
import os
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import os
|
|
||||||
import pytest
|
import pytest
|
||||||
|
from crewai_tools import tool
|
||||||
|
|
||||||
from crewai import Agent, Crew, Task
|
from crewai import Agent, Crew, Task
|
||||||
from crewai.agents.cache import CacheHandler
|
from crewai.agents.cache import CacheHandler
|
||||||
from crewai.agents.crew_agent_executor import CrewAgentExecutor
|
from crewai.agents.crew_agent_executor import CrewAgentExecutor
|
||||||
|
from crewai.agents.parser import AgentAction, CrewAgentParser, OutputParserException
|
||||||
from crewai.llm import LLM
|
from crewai.llm import LLM
|
||||||
from crewai.agents.parser import CrewAgentParser, OutputParserException
|
|
||||||
from crewai.tools.tool_calling import InstructorToolCalling
|
from crewai.tools.tool_calling import InstructorToolCalling
|
||||||
from crewai.tools.tool_usage import ToolUsage
|
from crewai.tools.tool_usage import ToolUsage
|
||||||
from crewai.tools.tool_usage_events import ToolUsageFinished
|
from crewai.tools.tool_usage_events import ToolUsageFinished
|
||||||
from crewai.utilities import RPMController
|
from crewai.utilities import RPMController
|
||||||
from crewai_tools import tool
|
|
||||||
from crewai.agents.parser import AgentAction
|
|
||||||
from crewai.utilities.events import Emitter
|
from crewai.utilities.events import Emitter
|
||||||
|
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ def test_agent_creation():
|
|||||||
|
|
||||||
def test_agent_default_values():
|
def test_agent_default_values():
|
||||||
agent = Agent(role="test role", goal="test goal", backstory="test backstory")
|
agent = Agent(role="test role", goal="test goal", backstory="test backstory")
|
||||||
assert agent.llm.model == "gpt-4o"
|
assert agent.llm.model == "gpt-4o-mini"
|
||||||
assert agent.allow_delegation is False
|
assert agent.allow_delegation is False
|
||||||
|
|
||||||
|
|
||||||
@@ -116,6 +116,7 @@ def test_custom_llm_temperature_preservation():
|
|||||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||||
def test_agent_execute_task():
|
def test_agent_execute_task():
|
||||||
from langchain_openai import ChatOpenAI
|
from langchain_openai import ChatOpenAI
|
||||||
|
|
||||||
from crewai import Task
|
from crewai import Task
|
||||||
|
|
||||||
agent = Agent(
|
agent = Agent(
|
||||||
@@ -206,7 +207,7 @@ def test_logging_tool_usage():
|
|||||||
verbose=True,
|
verbose=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
assert agent.llm.model == "gpt-4o"
|
assert agent.llm.model == "gpt-4o-mini"
|
||||||
assert agent.tools_handler.last_used_tool == {}
|
assert agent.tools_handler.last_used_tool == {}
|
||||||
task = Task(
|
task = Task(
|
||||||
description="What is 3 times 4?",
|
description="What is 3 times 4?",
|
||||||
@@ -602,6 +603,7 @@ def test_agent_respect_the_max_rpm_set(capsys):
|
|||||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||||
def test_agent_respect_the_max_rpm_set_over_crew_rpm(capsys):
|
def test_agent_respect_the_max_rpm_set_over_crew_rpm(capsys):
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from crewai_tools import tool
|
from crewai_tools import tool
|
||||||
|
|
||||||
@tool
|
@tool
|
||||||
@@ -693,6 +695,7 @@ def test_agent_without_max_rpm_respet_crew_rpm(capsys):
|
|||||||
@pytest.mark.vcr(filter_headers=["authorization"])
|
@pytest.mark.vcr(filter_headers=["authorization"])
|
||||||
def test_agent_error_on_parsing_tool(capsys):
|
def test_agent_error_on_parsing_tool(capsys):
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
from crewai_tools import tool
|
from crewai_tools import tool
|
||||||
|
|
||||||
@tool
|
@tool
|
||||||
@@ -855,7 +858,9 @@ def test_agent_function_calling_llm():
|
|||||||
tasks = [essay]
|
tasks = [essay]
|
||||||
crew = Crew(agents=[agent1], tasks=tasks)
|
crew = Crew(agents=[agent1], tasks=tasks)
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
|
|
||||||
import instructor
|
import instructor
|
||||||
|
|
||||||
from crewai.tools.tool_usage import ToolUsage
|
from crewai.tools.tool_usage import ToolUsage
|
||||||
|
|
||||||
with patch.object(
|
with patch.object(
|
||||||
|
|||||||
Reference in New Issue
Block a user