mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-05 15:09:22 +00:00
linted
This commit is contained in:
@@ -321,12 +321,8 @@ class EventListener(BaseEventListener):
|
||||
event.flow_name, list(source._methods.keys())
|
||||
)
|
||||
if not getattr(source, "suppress_flow_events", False):
|
||||
self.formatter.handle_flow_created(
|
||||
event.flow_name, str(source.flow_id)
|
||||
)
|
||||
self.formatter.handle_flow_started(
|
||||
event.flow_name, str(source.flow_id)
|
||||
)
|
||||
self.formatter.handle_flow_created(event.flow_name, str(source.flow_id))
|
||||
self.formatter.handle_flow_started(event.flow_name, str(source.flow_id))
|
||||
|
||||
@crewai_event_bus.on(FlowFinishedEvent)
|
||||
def on_flow_finished(source: Any, event: FlowFinishedEvent) -> None:
|
||||
|
||||
@@ -736,9 +736,7 @@ class TraceCollectionListener(BaseEventListener):
|
||||
|
||||
def _nested_in_flow_execution(self) -> bool:
|
||||
"""True when a crew runs inside a flow session (context or batch ownership)."""
|
||||
return (
|
||||
self._is_inside_active_flow_context() or self._flow_owns_trace_batch()
|
||||
)
|
||||
return self._is_inside_active_flow_context() or self._flow_owns_trace_batch()
|
||||
|
||||
def _initialize_crew_batch(self, source: Any, event: BaseEvent) -> None:
|
||||
"""Initialize trace batch.
|
||||
|
||||
@@ -9,7 +9,10 @@ from uuid import uuid4
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from crewai.flow.conversation import get_conversation_messages, get_conversational_config
|
||||
from crewai.flow.conversation import (
|
||||
get_conversation_messages,
|
||||
get_conversational_config,
|
||||
)
|
||||
from crewai.utilities.types import LLMMessage
|
||||
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ def append_message(
|
||||
messages = getattr(state, "messages", None)
|
||||
if messages is None:
|
||||
object.__setattr__(state, "messages", [])
|
||||
messages = getattr(state, "messages")
|
||||
messages = state.messages
|
||||
if isinstance(messages, list):
|
||||
messages.append(message)
|
||||
return
|
||||
|
||||
@@ -2320,13 +2320,20 @@ class Flow(BaseModel, Generic[T], metaclass=FlowMeta):
|
||||
restore_from_state_id: str | None,
|
||||
) -> Any:
|
||||
config = get_conversational_config(self) or self.conversational_config
|
||||
prompt = interactive_prompt or (config.interactive_prompt if config else "You: ")
|
||||
prompt = interactive_prompt or (
|
||||
config.interactive_prompt if config else "You: "
|
||||
)
|
||||
timeout = (
|
||||
interactive_timeout
|
||||
if interactive_timeout is not None
|
||||
else (config.interactive_timeout if config else None)
|
||||
)
|
||||
exits = {c.strip().lower() for c in (exit_commands or (config.exit_commands if config else ("exit", "quit")))}
|
||||
exits = {
|
||||
c.strip().lower()
|
||||
for c in (
|
||||
exit_commands or (config.exit_commands if config else ("exit", "quit"))
|
||||
)
|
||||
}
|
||||
sid = session_id
|
||||
if sid is None and inputs and "id" in inputs:
|
||||
sid = str(inputs["id"])
|
||||
@@ -2585,9 +2592,7 @@ class Flow(BaseModel, Generic[T], metaclass=FlowMeta):
|
||||
try:
|
||||
await asyncio.wrap_future(future)
|
||||
except Exception:
|
||||
logger.warning(
|
||||
"FlowStartedEvent handler failed", exc_info=True
|
||||
)
|
||||
logger.warning("FlowStartedEvent handler failed", exc_info=True)
|
||||
if self._should_defer_trace_finalization():
|
||||
object.__setattr__(self, "_conversation_trace_started", True)
|
||||
object.__setattr__(
|
||||
@@ -2599,9 +2604,7 @@ class Flow(BaseModel, Generic[T], metaclass=FlowMeta):
|
||||
TraceCollectionListener,
|
||||
)
|
||||
|
||||
TraceCollectionListener().batch_manager.defer_session_finalization = (
|
||||
True
|
||||
)
|
||||
TraceCollectionListener().batch_manager.defer_session_finalization = True
|
||||
if not self.suppress_flow_events:
|
||||
self._log_flow_event(
|
||||
f"Flow started with ID: {self.flow_id}", color="bold magenta"
|
||||
@@ -3890,9 +3893,8 @@ class Flow(BaseModel, Generic[T], metaclass=FlowMeta):
|
||||
return
|
||||
|
||||
result = self._method_outputs[-1] if self._method_outputs else None
|
||||
if (
|
||||
self._should_defer_trace_finalization()
|
||||
and getattr(self, "_conversation_trace_started", False)
|
||||
if self._should_defer_trace_finalization() and getattr(
|
||||
self, "_conversation_trace_started", False
|
||||
):
|
||||
started_id = getattr(self, "_conversation_flow_started_event_id", None)
|
||||
if started_id:
|
||||
|
||||
Reference in New Issue
Block a user