Skip to content

Commit

Permalink
Update AGS to Use AgentChat Declarative Config Serialization (#5261)
Browse files Browse the repository at this point in the history
<!-- Thank you for your contribution! Please review
https://microsoft.github.io/autogen/docs/Contribute before opening a
pull request. -->

<!-- Please add a reviewer to the assignee section when you create a PR.
If you don't have the access to it, we will shortly find a reviewer and
assign them to your PR. -->

## Why are these changes needed?

This PR updates AGS to use the declarative config serialization native
to AgentChat.
The effect? You can build your teams/artifacts directly in python, run
`team.dump_component()` and immediately run it in AGS.

Some change details:

- Removes ComponentFactory. Instead TeamManager just loads team specs
directly using `Team.load_component`.
- Some fixes to the UI to simplify drag and drop experience.  
- Improve layout of nodes...


<!-- Please give a short summary of the change and the problem this
solves. -->

## Related issue number

<!-- For example: "Closes #1234" -->
Closes #4439 
Closes #5172

## Checks

- [ ] I've included any doc changes needed for
https://microsoft.github.io/autogen/. See
https://microsoft.github.io/autogen/docs/Contribute#documentation to
build and test documentation locally.
- [ ] I've added tests (if relevant) corresponding to the changes
introduced in this PR.
- [ ] I've made sure all auto checks have passed.


cc @EItanya @nour-bouzid
  • Loading branch information
victordibia authored Jan 31, 2025
1 parent a1b08aa commit b2800d7
Show file tree
Hide file tree
Showing 49 changed files with 3,485 additions and 4,163 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,89 @@ After defining a team, users can test it in the Playground view to accomplish va

## Declarative Specification of Componenents

AutoGen Studio uses a declarative specification system to build its GUI components. At runtime, the AGS API loads these specifications into AutoGen AgentChat objects to address tasks.
AutoGen Studio is built on the declarative specification behaviors of AutoGen AgentChat. This allows users to define teams, agents, models, tools, and termination conditions in python and then dump them into a JSON file for use in AutoGen Studio.

Here's an example of a declarative team specification:
Here's an example of an agent team and how it is converted to a JSON file:

```python
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_agentchat.conditions import TextMentionTermination

agent = AssistantAgent(
name="weather_agent",
model_client=OpenAIChatCompletionClient(
model="gpt-4o-mini",
),
)

agent_team = RoundRobinGroupChat([agent], termination_condition=TextMentionTermination("TERMINATE"))
config = agent_team.dump_component()
print(config.model_dump_json())
```

```json
{
"version": "1.0.0",
"provider": "autogen_agentchat.teams.RoundRobinGroupChat",
"component_type": "team",
"name": "sample_team",
"participants": [
{
"component_type": "agent",
"name": "assistant_agent",
"agent_type": "AssistantAgent",
"system_message": "You are a helpful assistant. Solve tasks carefully. When done respond with TERMINATE",
"model_client": {
"component_type": "model",
"model": "gpt-4o-2024-08-06",
"model_type": "OpenAIChatCompletionClient"
},
"tools": []
"version": 1,
"component_version": 1,
"description": "A team that runs a group chat with participants taking turns in a round-robin fashion\n to publish a message to all.",
"label": "RoundRobinGroupChat",
"config": {
"participants": [
{
"provider": "autogen_agentchat.agents.AssistantAgent",
"component_type": "agent",
"version": 1,
"component_version": 1,
"description": "An agent that provides assistance with tool use.",
"label": "AssistantAgent",
"config": {
"name": "weather_agent",
"model_client": {
"provider": "autogen_ext.models.openai.OpenAIChatCompletionClient",
"component_type": "model",
"version": 1,
"component_version": 1,
"description": "Chat completion client for OpenAI hosted models.",
"label": "OpenAIChatCompletionClient",
"config": { "model": "gpt-4o-mini" }
},
"tools": [],
"handoffs": [],
"model_context": {
"provider": "autogen_core.model_context.UnboundedChatCompletionContext",
"component_type": "chat_completion_context",
"version": 1,
"component_version": 1,
"description": "An unbounded chat completion context that keeps a view of the all the messages.",
"label": "UnboundedChatCompletionContext",
"config": {}
},
"description": "An agent that provides assistance with ability to use tools.",
"system_message": "You are a helpful AI assistant. Solve tasks using your tools. Reply with TERMINATE when the task has been completed.",
"model_client_stream": false,
"reflect_on_tool_use": false,
"tool_call_summary_format": "{result}"
}
}
],
"termination_condition": {
"provider": "autogen_agentchat.conditions.TextMentionTermination",
"component_type": "termination",
"version": 1,
"component_version": 1,
"description": "Terminate the conversation if a specific text is mentioned.",
"label": "TextMentionTermination",
"config": { "text": "TERMINATE" }
}
],
"team_type": "RoundRobinGroupChat",
"termination_condition": {
"component_type": "termination",
"termination_type": "MaxMessageTermination",
"max_messages": 3
}
}
```

This example shows a team with a single agent, using the `RoundRobinGroupChat` type and a `MaxMessageTermination` condition limited to 3 messages.

```{note}
Work is currently in progress to make the entire AgentChat API declarative. This will allow all agentchat components to be `dumped` into the same declarative specification format used by AGS.
```
This example shows a team with a single agent, using the `RoundRobinGroupChat` type and a `TextMentionTermination` condition.

## Building an Agent Team

Expand Down
16 changes: 2 additions & 14 deletions python/packages/autogen-studio/autogenstudio/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
from .database.db_manager import DatabaseManager
from .datamodel import Agent, AgentConfig, Model, ModelConfig, Team, TeamConfig, Tool, ToolConfig
from .datamodel import Team
from .teammanager import TeamManager
from .version import __version__

__all__ = [
"Tool",
"Model",
"DatabaseManager",
"Team",
"Agent",
"ToolConfig",
"ModelConfig",
"TeamConfig",
"AgentConfig",
"TeamManager",
"__version__",
]
__all__ = ["DatabaseManager", "Team", "TeamManager", "__version__"]
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from .component_factory import Component, ComponentFactory
from .config_manager import ConfigurationManager
from .db_manager import DatabaseManager
from .gallery_builder import GalleryBuilder, create_default_gallery

__all__ = [
"DatabaseManager",
]
Loading

0 comments on commit b2800d7

Please sign in to comment.