Skip to content

python-v0.5.6

Latest
Compare
Choose a tag to compare
@ekzhu ekzhu released this 02 May 22:55
· 9 commits to main since this release
880a225

What's New

GraphFlow: customized workflows using directed graph

Should I say finally? Yes, finally, we have workflows in AutoGen. GraphFlow is a new team class as part of the AgentChat API. One way to think of GraphFlow is that it is a version of SelectorGroupChat but with a directed graph as the selector_func. However, it is actually more powerful, because the abstraction also supports concurrent agents.

Note: GraphFlow is still an experimental API. Watch out for changes in the future releases.

For more details, see our newly added user guide on GraphFlow.

If you are in a hurry, here is an example of creating a fan-out-fan-in workflow:

import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import DiGraphBuilder, GraphFlow
from autogen_agentchat.ui import Console
from autogen_ext.models.openai import OpenAIChatCompletionClient


async def main() -> None:
    # Create an OpenAI model client
    client = OpenAIChatCompletionClient(model="gpt-4.1-nano")

    # Create the writer agent
    writer = AssistantAgent(
        "writer",
        model_client=client,
        system_message="Draft a short paragraph on climate change.",
    )

    # Create two editor agents
    editor1 = AssistantAgent(
        "editor1", model_client=client, system_message="Edit the paragraph for grammar."
    )

    editor2 = AssistantAgent(
        "editor2", model_client=client, system_message="Edit the paragraph for style."
    )

    # Create the final reviewer agent
    final_reviewer = AssistantAgent(
        "final_reviewer",
        model_client=client,
        system_message="Consolidate the grammar and style edits into a final version.",
    )

    # Build the workflow graph
    builder = DiGraphBuilder()
    builder.add_node(writer).add_node(editor1).add_node(editor2).add_node(
        final_reviewer
    )

    # Fan-out from writer to editor1 and editor2
    builder.add_edge(writer, editor1)
    builder.add_edge(writer, editor2)

    # Fan-in both editors into final reviewer
    builder.add_edge(editor1, final_reviewer)
    builder.add_edge(editor2, final_reviewer)

    # Build and validate the graph
    graph = builder.build()

    # Create the flow
    flow = GraphFlow(
        participants=builder.get_participants(),
        graph=graph,
    )

    # Run the workflow
    await Console(flow.run_stream(task="Write a short biography of Steve Jobs."))

asyncio.run(main())

Major thanks to @abhinav-aegis for the initial design and implementation of this amazing feature!

Azure AI Agent Improvement

New Sample

  • A multi-agent PostgreSQL data management example by @mehrsa in #6443

Bug Fixes:

Dev Improvement

Other Python Related Changes

New Contributors

Full Changelog: python-v0.5.5...python-v0.5.6