mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
Merge branch 'main' into gl/feat/a2a-native-async
This commit is contained in:
@@ -839,6 +839,7 @@ def _delegate_to_a2a(
|
|||||||
context=context,
|
context=context,
|
||||||
tools=tools,
|
tools=tools,
|
||||||
agent_response_model=agent_response_model,
|
agent_response_model=agent_response_model,
|
||||||
|
remote_task_completed=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
if final_result is not None:
|
if final_result is not None:
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ from crewai.flow.async_feedback import (
|
|||||||
PendingFeedbackContext,
|
PendingFeedbackContext,
|
||||||
)
|
)
|
||||||
from crewai.flow.flow import Flow, and_, listen, or_, router, start
|
from crewai.flow.flow import Flow, and_, listen, or_, router, start
|
||||||
|
from crewai.flow.flow_config import flow_config
|
||||||
from crewai.flow.human_feedback import HumanFeedbackResult, human_feedback
|
from crewai.flow.human_feedback import HumanFeedbackResult, human_feedback
|
||||||
from crewai.flow.persistence import persist
|
from crewai.flow.persistence import persist
|
||||||
from crewai.flow.visualization import (
|
from crewai.flow.visualization import (
|
||||||
@@ -24,6 +25,7 @@ __all__ = [
|
|||||||
"PendingFeedbackContext",
|
"PendingFeedbackContext",
|
||||||
"and_",
|
"and_",
|
||||||
"build_flow_structure",
|
"build_flow_structure",
|
||||||
|
"flow_config",
|
||||||
"human_feedback",
|
"human_feedback",
|
||||||
"listen",
|
"listen",
|
||||||
"or_",
|
"or_",
|
||||||
|
|||||||
39
lib/crewai/src/crewai/flow/flow_config.py
Normal file
39
lib/crewai/src/crewai/flow/flow_config.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
"""Global Flow configuration.
|
||||||
|
|
||||||
|
This module provides a singleton configuration object that can be used to
|
||||||
|
customize Flow behavior at runtime.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import TYPE_CHECKING, Any
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from crewai.flow.async_feedback.types import HumanFeedbackProvider
|
||||||
|
|
||||||
|
|
||||||
|
class FlowConfig:
|
||||||
|
"""Global configuration for Flow execution.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
hitl_provider: The human-in-the-loop feedback provider.
|
||||||
|
Defaults to None (uses console input).
|
||||||
|
Can be overridden by deployments at startup.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self) -> None:
|
||||||
|
self._hitl_provider: HumanFeedbackProvider | None = None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hitl_provider(self) -> Any:
|
||||||
|
"""Get the configured HITL provider."""
|
||||||
|
return self._hitl_provider
|
||||||
|
|
||||||
|
@hitl_provider.setter
|
||||||
|
def hitl_provider(self, provider: Any) -> None:
|
||||||
|
"""Set the HITL provider."""
|
||||||
|
self._hitl_provider = provider
|
||||||
|
|
||||||
|
|
||||||
|
# Singleton instance
|
||||||
|
flow_config = FlowConfig()
|
||||||
@@ -283,11 +283,18 @@ def human_feedback(
|
|||||||
llm=llm if isinstance(llm, str) else None,
|
llm=llm if isinstance(llm, str) else None,
|
||||||
)
|
)
|
||||||
|
|
||||||
if provider is not None:
|
# Determine effective provider:
|
||||||
# Use custom provider (may raise HumanFeedbackPending)
|
effective_provider = provider
|
||||||
return provider.request_feedback(context, flow_instance)
|
if effective_provider is None:
|
||||||
|
from crewai.flow.flow_config import flow_config
|
||||||
|
|
||||||
|
effective_provider = flow_config.hitl_provider
|
||||||
|
|
||||||
|
if effective_provider is not None:
|
||||||
|
# Use provider (may raise HumanFeedbackPending for async providers)
|
||||||
|
return effective_provider.request_feedback(context, flow_instance)
|
||||||
else:
|
else:
|
||||||
# Use default console input
|
# Use default console input (local development)
|
||||||
return flow_instance._request_human_feedback(
|
return flow_instance._request_human_feedback(
|
||||||
message=message,
|
message=message,
|
||||||
output=method_output,
|
output=method_output,
|
||||||
|
|||||||
Reference in New Issue
Block a user