mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-01 23:32:39 +00:00
fixed linter issues
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
import os
|
import shutil
|
||||||
import re
|
import subprocess
|
||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
import traceback
|
|
||||||
import uuid
|
|
||||||
from typing import Any, Callable, Dict, List, Literal, Optional, Sequence, Tuple, Type, Union
|
from typing import Any, Callable, Dict, List, Literal, Optional, Sequence, Tuple, Type, Union
|
||||||
|
|
||||||
from pydantic import Field, InstanceOf, PrivateAttr, model_validator
|
from pydantic import Field, InstanceOf, PrivateAttr, model_validator
|
||||||
|
|||||||
@@ -65,3 +65,57 @@ from .memory_events import (
|
|||||||
# events
|
# events
|
||||||
from .event_listener import EventListener
|
from .event_listener import EventListener
|
||||||
from .third_party.agentops_listener import agentops_listener
|
from .third_party.agentops_listener import agentops_listener
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"EventListener",
|
||||||
|
"agentops_listener",
|
||||||
|
"CrewAIEventsBus",
|
||||||
|
"crewai_event_bus",
|
||||||
|
"AgentExecutionStartedEvent",
|
||||||
|
"AgentExecutionCompletedEvent",
|
||||||
|
"AgentExecutionErrorEvent",
|
||||||
|
"TaskStartedEvent",
|
||||||
|
"TaskCompletedEvent",
|
||||||
|
"TaskFailedEvent",
|
||||||
|
"TaskEvaluationEvent",
|
||||||
|
"FlowCreatedEvent",
|
||||||
|
"FlowStartedEvent",
|
||||||
|
"FlowFinishedEvent",
|
||||||
|
"FlowPlotEvent",
|
||||||
|
"MethodExecutionStartedEvent",
|
||||||
|
"MethodExecutionFinishedEvent",
|
||||||
|
"MethodExecutionFailedEvent",
|
||||||
|
"LLMCallCompletedEvent",
|
||||||
|
"LLMCallFailedEvent",
|
||||||
|
"LLMCallStartedEvent",
|
||||||
|
"LLMCallType",
|
||||||
|
"LLMStreamChunkEvent",
|
||||||
|
"MemorySaveStartedEvent",
|
||||||
|
"MemorySaveCompletedEvent",
|
||||||
|
"MemorySaveFailedEvent",
|
||||||
|
"MemoryQueryStartedEvent",
|
||||||
|
"MemoryQueryCompletedEvent",
|
||||||
|
"MemoryQueryFailedEvent",
|
||||||
|
"MemoryRetrievalStartedEvent",
|
||||||
|
"MemoryRetrievalCompletedEvent",
|
||||||
|
"EventListener",
|
||||||
|
"agentops_listener",
|
||||||
|
"CrewKickoffStartedEvent",
|
||||||
|
"CrewKickoffCompletedEvent",
|
||||||
|
"CrewKickoffFailedEvent",
|
||||||
|
"CrewTrainStartedEvent",
|
||||||
|
"CrewTrainCompletedEvent",
|
||||||
|
"CrewTrainFailedEvent",
|
||||||
|
"CrewTestStartedEvent",
|
||||||
|
"CrewTestCompletedEvent",
|
||||||
|
"CrewTestFailedEvent",
|
||||||
|
"LLMGuardrailCompletedEvent",
|
||||||
|
"LLMGuardrailStartedEvent",
|
||||||
|
"ToolUsageFinishedEvent",
|
||||||
|
"ToolUsageErrorEvent",
|
||||||
|
"ToolUsageStartedEvent",
|
||||||
|
"ToolExecutionErrorEvent",
|
||||||
|
"ToolSelectionErrorEvent",
|
||||||
|
"ToolUsageEvent",
|
||||||
|
"ToolValidateInputErrorEvent",
|
||||||
|
]
|
||||||
|
|||||||
@@ -2489,7 +2489,7 @@ def test_using_contextual_memory():
|
|||||||
memory=True,
|
memory=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch.object(ContextualMemory, "build_context_for_task") as contextual_mem:
|
with patch.object(ContextualMemory, "build_context_for_task", return_value="") as contextual_mem:
|
||||||
crew.kickoff()
|
crew.kickoff()
|
||||||
contextual_mem.assert_called_once()
|
contextual_mem.assert_called_once()
|
||||||
|
|
||||||
@@ -2500,35 +2500,35 @@ def test_memory_events_are_emitted():
|
|||||||
events = defaultdict(list)
|
events = defaultdict(list)
|
||||||
|
|
||||||
@crewai_event_bus.on(MemorySaveStartedEvent)
|
@crewai_event_bus.on(MemorySaveStartedEvent)
|
||||||
def handle_llm_failed(source, event):
|
def handle_memory_save_started(source, event):
|
||||||
events["MemorySaveStartedEvent"].append(event)
|
events["MemorySaveStartedEvent"].append(event)
|
||||||
|
|
||||||
@crewai_event_bus.on(MemorySaveCompletedEvent)
|
@crewai_event_bus.on(MemorySaveCompletedEvent)
|
||||||
def handle_llm_started(source, event):
|
def handle_memory_save_completed(source, event):
|
||||||
events["MemorySaveCompletedEvent"].append(event)
|
events["MemorySaveCompletedEvent"].append(event)
|
||||||
|
|
||||||
@crewai_event_bus.on(MemorySaveFailedEvent)
|
@crewai_event_bus.on(MemorySaveFailedEvent)
|
||||||
def handle_llm_completed(source, event):
|
def handle_memory_save_failed(source, event):
|
||||||
events["MemorySaveFailedEvent"].append(event)
|
events["MemorySaveFailedEvent"].append(event)
|
||||||
|
|
||||||
@crewai_event_bus.on(MemoryQueryStartedEvent)
|
@crewai_event_bus.on(MemoryQueryStartedEvent)
|
||||||
def handle_llm_failed(source, event):
|
def handle_memory_query_started(source, event):
|
||||||
events["MemoryQueryStartedEvent"].append(event)
|
events["MemoryQueryStartedEvent"].append(event)
|
||||||
|
|
||||||
@crewai_event_bus.on(MemoryQueryCompletedEvent)
|
@crewai_event_bus.on(MemoryQueryCompletedEvent)
|
||||||
def handle_llm_started(source, event):
|
def handle_memory_query_completed(source, event):
|
||||||
events["MemoryQueryCompletedEvent"].append(event)
|
events["MemoryQueryCompletedEvent"].append(event)
|
||||||
|
|
||||||
@crewai_event_bus.on(MemoryQueryFailedEvent)
|
@crewai_event_bus.on(MemoryQueryFailedEvent)
|
||||||
def handle_llm_completed(source, event):
|
def handle_memory_query_failed(source, event):
|
||||||
events["MemoryQueryFailedEvent"].append(event)
|
events["MemoryQueryFailedEvent"].append(event)
|
||||||
|
|
||||||
@crewai_event_bus.on(MemoryRetrievalStartedEvent)
|
@crewai_event_bus.on(MemoryRetrievalStartedEvent)
|
||||||
def handle_llm_completed(source, event):
|
def handle_memory_retrieval_started(source, event):
|
||||||
events["MemoryRetrievalStartedEvent"].append(event)
|
events["MemoryRetrievalStartedEvent"].append(event)
|
||||||
|
|
||||||
@crewai_event_bus.on(MemoryRetrievalCompletedEvent)
|
@crewai_event_bus.on(MemoryRetrievalCompletedEvent)
|
||||||
def handle_llm_completed(source, event):
|
def handle_memory_retrieval_completed(source, event):
|
||||||
events["MemoryRetrievalCompletedEvent"].append(event)
|
events["MemoryRetrievalCompletedEvent"].append(event)
|
||||||
|
|
||||||
math_researcher = Agent(
|
math_researcher = Agent(
|
||||||
@@ -2584,7 +2584,7 @@ def test_using_contextual_memory_with_long_term_memory():
|
|||||||
long_term_memory=LongTermMemory(),
|
long_term_memory=LongTermMemory(),
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch.object(ContextualMemory, "build_context_for_task") as contextual_mem:
|
with patch.object(ContextualMemory, "build_context_for_task", return_value="") as contextual_mem:
|
||||||
crew.kickoff()
|
crew.kickoff()
|
||||||
contextual_mem.assert_called_once()
|
contextual_mem.assert_called_once()
|
||||||
assert crew.memory is False
|
assert crew.memory is False
|
||||||
@@ -2685,7 +2685,7 @@ def test_using_contextual_memory_with_short_term_memory():
|
|||||||
short_term_memory=ShortTermMemory(),
|
short_term_memory=ShortTermMemory(),
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch.object(ContextualMemory, "build_context_for_task") as contextual_mem:
|
with patch.object(ContextualMemory, "build_context_for_task", return_value="") as contextual_mem:
|
||||||
crew.kickoff()
|
crew.kickoff()
|
||||||
contextual_mem.assert_called_once()
|
contextual_mem.assert_called_once()
|
||||||
assert crew.memory is False
|
assert crew.memory is False
|
||||||
@@ -2714,7 +2714,7 @@ def test_disabled_memory_using_contextual_memory():
|
|||||||
memory=False,
|
memory=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
with patch.object(ContextualMemory, "build_context_for_task") as contextual_mem:
|
with patch.object(ContextualMemory, "build_context_for_task", return_value="") as contextual_mem:
|
||||||
crew.kickoff()
|
crew.kickoff()
|
||||||
contextual_mem.assert_not_called()
|
contextual_mem.assert_not_called()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user