mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Update autogen-migration samples
This commit is contained in:
@@ -1,25 +1,17 @@
|
||||
# /// script
|
||||
# requires-python = ">=3.10"
|
||||
# dependencies = [
|
||||
# "autogen-agentchat",
|
||||
# "autogen-ext[openai]",
|
||||
# ]
|
||||
# ///
|
||||
# Run with any PEP 723 compatible runner, e.g.:
|
||||
# uv run samples/autogen-migration/orchestrations/01_round_robin_group_chat.py
|
||||
|
||||
# Copyright (c) Microsoft. All rights reserved.
|
||||
"""AutoGen RoundRobinGroupChat vs Agent Framework GroupChatBuilder/SequentialBuilder.
|
||||
|
||||
Demonstrates sequential agent orchestration where agents take turns processing
|
||||
the task in a round-robin fashion.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
|
||||
from agent_framework import Message
|
||||
from dotenv import load_dotenv
|
||||
|
||||
"""AutoGen RoundRobinGroupChat vs Agent Framework GroupChatBuilder/SequentialBuilder.
|
||||
|
||||
Demonstrates sequential agent orchestration where agents take turns processing
|
||||
the task in a round-robin fashion.
|
||||
"""
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
@@ -98,7 +90,7 @@ async def run_agent_framework() -> None:
|
||||
print("[Agent Framework] Sequential conversation:")
|
||||
async for event in workflow.run("Create a brief summary about electric vehicles", stream=True):
|
||||
if event.type == "output" and isinstance(event.data, list):
|
||||
for message in event.data:
|
||||
for message in event.data: # type: ignore
|
||||
if isinstance(message, Message) and message.role == "assistant" and message.text:
|
||||
print(f"---------- {message.author_name} ----------")
|
||||
print(message.text)
|
||||
@@ -144,9 +136,7 @@ async def run_agent_framework_with_cycle() -> None:
|
||||
if last_message and "APPROVED" in last_message.text:
|
||||
await context.yield_output("Content approved.")
|
||||
else:
|
||||
await context.send_message(
|
||||
AgentExecutorRequest(messages=response.full_conversation, should_respond=True)
|
||||
)
|
||||
await context.send_message(AgentExecutorRequest(messages=response.full_conversation, should_respond=True))
|
||||
|
||||
workflow = (
|
||||
WorkflowBuilder(start_executor=researcher)
|
||||
|
||||
@@ -1,25 +1,17 @@
|
||||
# /// script
|
||||
# requires-python = ">=3.10"
|
||||
# dependencies = [
|
||||
# "autogen-agentchat",
|
||||
# "autogen-ext[openai]",
|
||||
# ]
|
||||
# ///
|
||||
# Run with any PEP 723 compatible runner, e.g.:
|
||||
# uv run samples/autogen-migration/orchestrations/02_selector_group_chat.py
|
||||
|
||||
# Copyright (c) Microsoft. All rights reserved.
|
||||
"""AutoGen SelectorGroupChat vs Agent Framework GroupChatBuilder.
|
||||
|
||||
Demonstrates LLM-based speaker selection where an orchestrator decides
|
||||
which agent should speak next based on the conversation context.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
|
||||
from agent_framework import Message
|
||||
from dotenv import load_dotenv
|
||||
|
||||
"""AutoGen SelectorGroupChat vs Agent Framework GroupChatBuilder.
|
||||
|
||||
Demonstrates LLM-based speaker selection where an orchestrator decides
|
||||
which agent should speak next based on the conversation context.
|
||||
"""
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
@@ -113,7 +105,7 @@ async def run_agent_framework() -> None:
|
||||
print("[Agent Framework] Group chat conversation:")
|
||||
async for event in workflow.run("How do I connect to a PostgreSQL database using Python?", stream=True):
|
||||
if event.type == "output" and isinstance(event.data, list):
|
||||
for message in event.data:
|
||||
for message in event.data: # type: ignore
|
||||
if isinstance(message, Message) and message.role == "assistant" and message.text:
|
||||
print(f"---------- {message.author_name} ----------")
|
||||
print(message.text)
|
||||
|
||||
@@ -1,19 +1,4 @@
|
||||
# /// script
|
||||
# requires-python = ">=3.10"
|
||||
# dependencies = [
|
||||
# "autogen-agentchat",
|
||||
# "autogen-ext[openai]",
|
||||
# ]
|
||||
# ///
|
||||
# Run with any PEP 723 compatible runner, e.g.:
|
||||
# uv run samples/autogen-migration/orchestrations/03_swarm.py
|
||||
|
||||
# Copyright (c) Microsoft. All rights reserved.
|
||||
"""AutoGen Swarm pattern vs Agent Framework HandoffBuilder.
|
||||
|
||||
Demonstrates agent handoff coordination where agents can transfer control
|
||||
to other specialized agents based on the task requirements.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from typing import Any
|
||||
@@ -21,6 +6,12 @@ from typing import Any
|
||||
from agent_framework import AgentResponseUpdate, WorkflowEvent
|
||||
from dotenv import load_dotenv
|
||||
|
||||
"""AutoGen Swarm pattern vs Agent Framework HandoffBuilder.
|
||||
|
||||
Demonstrates agent handoff coordination where agents can transfer control
|
||||
to other specialized agents based on the task requirements.
|
||||
"""
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
|
||||
@@ -1,19 +1,4 @@
|
||||
# /// script
|
||||
# requires-python = ">=3.10"
|
||||
# dependencies = [
|
||||
# "autogen-agentchat",
|
||||
# "autogen-ext[openai]",
|
||||
# ]
|
||||
# ///
|
||||
# Run with any PEP 723 compatible runner, e.g.:
|
||||
# uv run samples/autogen-migration/orchestrations/04_magentic_one.py
|
||||
|
||||
# Copyright (c) Microsoft. All rights reserved.
|
||||
"""AutoGen MagenticOneGroupChat vs Agent Framework MagenticBuilder.
|
||||
|
||||
Demonstrates orchestrated multi-agent workflows with a central coordinator
|
||||
managing specialized agents for complex tasks.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
@@ -27,6 +12,12 @@ from agent_framework import (
|
||||
from agent_framework.orchestrations import MagenticProgressLedger
|
||||
from dotenv import load_dotenv
|
||||
|
||||
"""AutoGen MagenticOneGroupChat vs Agent Framework MagenticBuilder.
|
||||
|
||||
Demonstrates orchestrated multi-agent workflows with a central coordinator
|
||||
managing specialized agents for complex tasks.
|
||||
"""
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user