mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
Fix CI failures: remove unused imports and add streaming parameters to agent adapters and test mocks
Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from typing import Any, AsyncIterable, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from pydantic import Field, PrivateAttr
|
from pydantic import Field, PrivateAttr
|
||||||
|
|
||||||
@@ -22,7 +22,6 @@ from crewai.utilities.events.agent_events import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from langchain_core.messages import ToolMessage
|
|
||||||
from langgraph.checkpoint.memory import MemorySaver
|
from langgraph.checkpoint.memory import MemorySaver
|
||||||
from langgraph.prebuilt import create_react_agent
|
from langgraph.prebuilt import create_react_agent
|
||||||
|
|
||||||
@@ -126,6 +125,8 @@ class LangGraphAgentAdapter(BaseAgentAdapter):
|
|||||||
task: Any,
|
task: Any,
|
||||||
context: Optional[str] = None,
|
context: Optional[str] = None,
|
||||||
tools: Optional[List[BaseTool]] = None,
|
tools: Optional[List[BaseTool]] = None,
|
||||||
|
stream: bool = False,
|
||||||
|
stream_callback: Optional[Any] = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Execute a task using the LangGraph workflow."""
|
"""Execute a task using the LangGraph workflow."""
|
||||||
self.create_agent_executor(tools)
|
self.create_agent_executor(tools)
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ class OpenAIAgentAdapter(BaseAgentAdapter):
|
|||||||
task: Any,
|
task: Any,
|
||||||
context: Optional[str] = None,
|
context: Optional[str] = None,
|
||||||
tools: Optional[List[BaseTool]] = None,
|
tools: Optional[List[BaseTool]] = None,
|
||||||
|
stream: bool = False,
|
||||||
|
stream_callback: Optional[Any] = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Execute a task using the OpenAI Assistant"""
|
"""Execute a task using the OpenAI Assistant"""
|
||||||
self._converter_adapter.configure_structured_output(task)
|
self._converter_adapter.configure_structured_output(task)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ from crewai.security.security_config import SecurityConfig
|
|||||||
from crewai.tools.base_tool import BaseTool, Tool
|
from crewai.tools.base_tool import BaseTool, Tool
|
||||||
from crewai.utilities import I18N, Logger, RPMController
|
from crewai.utilities import I18N, Logger, RPMController
|
||||||
from crewai.utilities.config import process_config
|
from crewai.utilities.config import process_config
|
||||||
from crewai.utilities.converter import Converter
|
|
||||||
from crewai.utilities.string_utils import interpolate_only
|
from crewai.utilities.string_utils import interpolate_only
|
||||||
|
|
||||||
T = TypeVar("T", bound="BaseAgent")
|
T = TypeVar("T", bound="BaseAgent")
|
||||||
|
|||||||
@@ -211,7 +211,6 @@ def test_llm_stream_chunk_to_crew_stream_chunk():
|
|||||||
|
|
||||||
llm_event = LLMStreamChunkEvent(chunk="test chunk")
|
llm_event = LLMStreamChunkEvent(chunk="test chunk")
|
||||||
|
|
||||||
from crewai.utilities.events.crewai_event_bus import crewai_event_bus
|
|
||||||
crewai_event_bus.emit(mock_source, llm_event)
|
crewai_event_bus.emit(mock_source, llm_event)
|
||||||
|
|
||||||
assert len(received_crew_chunks) == 1
|
assert len(received_crew_chunks) == 1
|
||||||
@@ -230,6 +229,7 @@ def test_multiple_agents_streaming():
|
|||||||
with patch('crewai.llm.LLM') as mock_llm_class:
|
with patch('crewai.llm.LLM') as mock_llm_class:
|
||||||
mock_llm = Mock()
|
mock_llm = Mock()
|
||||||
mock_llm.call.return_value = "Agent response"
|
mock_llm.call.return_value = "Agent response"
|
||||||
|
mock_llm.supports_stop_words = True
|
||||||
mock_llm_class.return_value = mock_llm
|
mock_llm_class.return_value = mock_llm
|
||||||
|
|
||||||
agent1 = Agent(
|
agent1 = Agent(
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ def test_guardrail_error_in_context():
|
|||||||
# Mock execute_task to succeed on second attempt
|
# Mock execute_task to succeed on second attempt
|
||||||
first_call = True
|
first_call = True
|
||||||
|
|
||||||
def execute_task(task, context, tools):
|
def execute_task(task, context, tools, stream=False, stream_callback=None):
|
||||||
nonlocal first_call
|
nonlocal first_call
|
||||||
if first_call:
|
if first_call:
|
||||||
first_call = False
|
first_call = False
|
||||||
|
|||||||
Reference in New Issue
Block a user