mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
[BREAKING] Python: Move single-config fluent methods to constructor parameters (#3693)
* Move single-config fluent methods to constructor parameters * Updates * Adjust magentic and group chat
This commit is contained in:
committed by
GitHub
Unverified
parent
5d355ac507
commit
74ac470a56
@@ -141,9 +141,8 @@ def create_sub_workflow() -> WorkflowExecutor:
|
||||
print("🚀 Setting up sub-workflow...")
|
||||
|
||||
processing_workflow = (
|
||||
WorkflowBuilder()
|
||||
WorkflowBuilder(start_executor="text_processor")
|
||||
.register_executor(TextProcessor, name="text_processor")
|
||||
.set_start_executor("text_processor")
|
||||
.build()
|
||||
)
|
||||
|
||||
@@ -155,10 +154,9 @@ async def main():
|
||||
print("🔧 Setting up parent workflow...")
|
||||
# Step 1: Create the parent workflow
|
||||
main_workflow = (
|
||||
WorkflowBuilder()
|
||||
WorkflowBuilder(start_executor="text_orchestrator")
|
||||
.register_executor(TextProcessingOrchestrator, name="text_orchestrator")
|
||||
.register_executor(create_sub_workflow, name="text_processor_workflow")
|
||||
.set_start_executor("text_orchestrator")
|
||||
.add_edge("text_orchestrator", "text_processor_workflow")
|
||||
.add_edge("text_processor_workflow", "text_orchestrator")
|
||||
.build()
|
||||
|
||||
@@ -88,7 +88,7 @@ async def main() -> None:
|
||||
)
|
||||
|
||||
# Build the inner (sub) workflow with the agent
|
||||
inner_workflow = SequentialBuilder().participants([inner_agent]).build()
|
||||
inner_workflow = SequentialBuilder(participants=[inner_agent]).build()
|
||||
|
||||
# Wrap the inner workflow in a WorkflowExecutor to use it as a sub-workflow
|
||||
subworkflow_executor = WorkflowExecutor(
|
||||
@@ -97,7 +97,7 @@ async def main() -> None:
|
||||
)
|
||||
|
||||
# Build the outer (parent) workflow containing the sub-workflow
|
||||
outer_workflow = SequentialBuilder().participants([subworkflow_executor]).build()
|
||||
outer_workflow = SequentialBuilder(participants=[subworkflow_executor]).build()
|
||||
|
||||
# Define custom context that will flow through to the sub-workflow's agent
|
||||
user_token = {
|
||||
|
||||
+2
-4
@@ -170,12 +170,11 @@ def build_resource_request_distribution_workflow() -> Workflow:
|
||||
raise ValueError("Received more responses than expected")
|
||||
|
||||
return (
|
||||
WorkflowBuilder()
|
||||
WorkflowBuilder(start_executor="orchestrator")
|
||||
.register_executor(lambda: RequestDistribution("orchestrator"), name="orchestrator")
|
||||
.register_executor(lambda: ResourceRequester("resource_requester"), name="resource_requester")
|
||||
.register_executor(lambda: PolicyChecker("policy_checker"), name="policy_checker")
|
||||
.register_executor(lambda: ResultCollector("result_collector"), name="result_collector")
|
||||
.set_start_executor("orchestrator")
|
||||
.add_edge("orchestrator", "resource_requester")
|
||||
.add_edge("orchestrator", "policy_checker")
|
||||
.add_edge("resource_requester", "result_collector")
|
||||
@@ -289,7 +288,7 @@ class PolicyEngine(Executor):
|
||||
async def main() -> None:
|
||||
# Build the main workflow
|
||||
main_workflow = (
|
||||
WorkflowBuilder()
|
||||
WorkflowBuilder(start_executor="sub_workflow_executor")
|
||||
.register_executor(lambda: ResourceAllocator("resource_allocator"), name="resource_allocator")
|
||||
.register_executor(lambda: PolicyEngine("policy_engine"), name="policy_engine")
|
||||
.register_executor(
|
||||
@@ -303,7 +302,6 @@ async def main() -> None:
|
||||
),
|
||||
name="sub_workflow_executor",
|
||||
)
|
||||
.set_start_executor("sub_workflow_executor")
|
||||
.add_edge("sub_workflow_executor", "resource_allocator")
|
||||
.add_edge("resource_allocator", "sub_workflow_executor")
|
||||
.add_edge("sub_workflow_executor", "policy_engine")
|
||||
|
||||
+2
-4
@@ -154,11 +154,10 @@ def build_email_address_validation_workflow() -> Workflow:
|
||||
|
||||
# Build the workflow
|
||||
return (
|
||||
WorkflowBuilder()
|
||||
WorkflowBuilder(start_executor="email_sanitizer")
|
||||
.register_executor(lambda: EmailSanitizer(id="email_sanitizer"), name="email_sanitizer")
|
||||
.register_executor(lambda: EmailFormatValidator(id="email_format_validator"), name="email_format_validator")
|
||||
.register_executor(lambda: DomainValidator(id="domain_validator"), name="domain_validator")
|
||||
.set_start_executor("email_sanitizer")
|
||||
.add_edge("email_sanitizer", "email_format_validator")
|
||||
.add_edge("email_format_validator", "domain_validator")
|
||||
.build()
|
||||
@@ -270,7 +269,7 @@ async def main() -> None:
|
||||
|
||||
# Build the main workflow
|
||||
workflow = (
|
||||
WorkflowBuilder()
|
||||
WorkflowBuilder(start_executor="smart_email_orchestrator")
|
||||
.register_executor(
|
||||
lambda: SmartEmailOrchestrator(id="smart_email_orchestrator", approved_domains=approved_domains),
|
||||
name="smart_email_orchestrator",
|
||||
@@ -280,7 +279,6 @@ async def main() -> None:
|
||||
lambda: WorkflowExecutor(build_email_address_validation_workflow(), id="email_validation_workflow"),
|
||||
name="email_validation_workflow",
|
||||
)
|
||||
.set_start_executor("smart_email_orchestrator")
|
||||
.add_edge("smart_email_orchestrator", "email_validation_workflow")
|
||||
.add_edge("email_validation_workflow", "smart_email_orchestrator")
|
||||
.add_edge("smart_email_orchestrator", "email_delivery")
|
||||
|
||||
Reference in New Issue
Block a user