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
@@ -87,7 +87,7 @@ async def run_agent_framework_example(prompt: str) -> Sequence[list[ChatMessage]
|
||||
name="chemistry",
|
||||
)
|
||||
|
||||
workflow = ConcurrentBuilder().participants([physics, chemistry]).build()
|
||||
workflow = ConcurrentBuilder(participants=[physics, chemistry]).build()
|
||||
|
||||
outputs: list[list[ChatMessage]] = []
|
||||
async for event in workflow.run(prompt, stream=True):
|
||||
|
||||
@@ -7,8 +7,9 @@ import sys
|
||||
from collections.abc import Sequence
|
||||
from typing import Any, cast
|
||||
|
||||
from agent_framework import ChatAgent, ChatMessage, GroupChatBuilderWorkflowEvent
|
||||
from agent_framework import ChatAgent, ChatMessage
|
||||
from agent_framework.azure import AzureOpenAIChatClient, AzureOpenAIResponsesClient
|
||||
from agent_framework.orchestrations import GroupChatBuilder
|
||||
from azure.identity import AzureCliCredential
|
||||
from semantic_kernel.agents import Agent, ChatCompletionAgent, GroupChatOrchestration
|
||||
from semantic_kernel.agents.orchestration.group_chat import (
|
||||
@@ -231,12 +232,10 @@ async def run_agent_framework_example(task: str) -> str:
|
||||
chat_client=AzureOpenAIResponsesClient(credential=credential),
|
||||
)
|
||||
|
||||
workflow = (
|
||||
GroupChatBuilder()
|
||||
.with_orchestrator(agent=AzureOpenAIChatClient(credential=credential).as_agent())
|
||||
.participants([researcher, planner])
|
||||
.build()
|
||||
)
|
||||
workflow = GroupChatBuilder(
|
||||
participants=[researcher, planner],
|
||||
orchestrator_agent=AzureOpenAIChatClient(credential=credential).as_agent(),
|
||||
).build()
|
||||
|
||||
final_response = ""
|
||||
async for event in workflow.run(task, stream=True):
|
||||
|
||||
@@ -6,8 +6,9 @@ import asyncio
|
||||
from collections.abc import Sequence
|
||||
from typing import cast
|
||||
|
||||
from agent_framework import ChatAgent, HostedCodeInterpreterTool, MagenticBuilderWorkflowEvent
|
||||
from agent_framework import ChatAgent, HostedCodeInterpreterTool
|
||||
from agent_framework.openai import OpenAIChatClient, OpenAIResponsesClient
|
||||
from agent_framework.orchestrations import MagenticBuilder
|
||||
from semantic_kernel.agents import (
|
||||
Agent,
|
||||
ChatCompletionAgent,
|
||||
@@ -144,7 +145,7 @@ async def run_agent_framework_example(prompt: str) -> str | None:
|
||||
chat_client=OpenAIChatClient(),
|
||||
)
|
||||
|
||||
workflow = MagenticBuilder().participants([researcher, coder]).with_manager(agent=manager_agent).build()
|
||||
workflow = MagenticBuilder(participants=[researcher, coder], manager_agent=manager_agent).build()
|
||||
|
||||
final_text: str | None = None
|
||||
async for event in workflow.run(prompt, stream=True):
|
||||
|
||||
@@ -74,7 +74,7 @@ async def run_agent_framework_example(prompt: str) -> list[ChatMessage]:
|
||||
name="reviewer",
|
||||
)
|
||||
|
||||
workflow = SequentialBuilder().participants([writer, reviewer]).build()
|
||||
workflow = SequentialBuilder(participants=[writer, reviewer]).build()
|
||||
|
||||
conversation_outputs: list[list[ChatMessage]] = []
|
||||
async for event in workflow.run(prompt, stream=True):
|
||||
|
||||
@@ -221,12 +221,11 @@ async def run_agent_framework_workflow_example() -> str | None:
|
||||
aggregate = FanInExecutor(required_cycles=3)
|
||||
|
||||
workflow = (
|
||||
WorkflowBuilder()
|
||||
WorkflowBuilder(start_executor=kickoff)
|
||||
.add_edge(kickoff, step_a)
|
||||
.add_edge(kickoff, step_b)
|
||||
.add_fan_in_edges([step_a, step_b], aggregate)
|
||||
.add_edge(aggregate, kickoff)
|
||||
.set_start_executor(kickoff)
|
||||
.build()
|
||||
)
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ def _build_inner_workflow() -> WorkflowExecutor:
|
||||
inner_echo = InnerEchoExecutor()
|
||||
inner_repeat = InnerRepeatExecutor()
|
||||
|
||||
inner_workflow = WorkflowBuilder().set_start_executor(inner_echo).add_edge(inner_echo, inner_repeat).build()
|
||||
inner_workflow = WorkflowBuilder(start_executor=inner_echo).add_edge(inner_echo, inner_repeat).build()
|
||||
|
||||
return WorkflowExecutor(inner_workflow, id="inner_workflow")
|
||||
|
||||
@@ -246,8 +246,7 @@ async def run_agent_framework_nested_workflow(initial_message: str) -> Sequence[
|
||||
collector = CollectResultExecutor()
|
||||
|
||||
outer_workflow = (
|
||||
WorkflowBuilder()
|
||||
.set_start_executor(kickoff)
|
||||
WorkflowBuilder(start_executor=kickoff)
|
||||
.add_edge(kickoff, outer_echo)
|
||||
.add_edge(outer_echo, outer_repeat)
|
||||
.add_edge(outer_repeat, inner_executor)
|
||||
|
||||
Reference in New Issue
Block a user