Skip to content

Commit 2f43005

Browse files
authored
Improve Gallery Editor UX in AGS (#5613)
<!-- 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? Fixes the problem where Gallery items could only be modified via JSON This PR does the following - Refactor TeamBuilder to have modular component editor UI primarily focused on editing each component type. - Refactor the Gallery UX - improve layout to use tabs for each component type - enable editing of each component item by reusing the component editor - Enable switching between form editing and UI editing for coponent editor view This way, gallery items can be readily modified and then reused in the component library in team builder. It also implements an upate to the Gallery data structure to make it more intuitive - it has a components field that has teams, agents, models ... <img width="1598" alt="image" src="https://github.com./user-attachments/assets/3c3a228a-0bd2-4fc1-85ec-c9685c80bf72" /> <img width="1614" alt="image" src="https://github.com./user-attachments/assets/5b6ed840-9c48-47bc-8c17-2aa50c7dcb99" /> <!-- Please give a short summary of the change and the problem this solves. --> ## Related issue number <!-- For example: "Closes #1234" --> Closes #5465 Closes #5047 cc @nour-bouzid @balakreshnan @EItanya @joslat @IustinT @LeonG7 ## Checks - [ ] I've included any doc changes needed for <https://microsoft.github.io/autogen/>. See <https://github.com./microsoft/autogen/blob/main/CONTRIBUTING.md> 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.
1 parent 34d30b5 commit 2f43005

29 files changed

+2758
-1058
lines changed

python/packages/autogen-studio/autogenstudio/datamodel/__init__.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from .types import (
33
Gallery,
44
GalleryComponents,
5-
GalleryItems,
65
GalleryMetadata,
76
LLMCallEventMessage,
87
MessageConfig,
@@ -24,4 +23,7 @@
2423
"Response",
2524
"SocketMessage",
2625
"LLMCallEventMessage",
26+
"Gallery",
27+
"GalleryComponents",
28+
"GalleryMetadata",
2729
]

python/packages/autogen-studio/autogenstudio/datamodel/types.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,15 @@ class GalleryComponents(BaseModel):
5252
models: List[ComponentModel]
5353
tools: List[ComponentModel]
5454
terminations: List[ComponentModel]
55-
56-
57-
class GalleryItems(BaseModel):
5855
teams: List[ComponentModel]
59-
components: GalleryComponents
6056

6157

6258
class Gallery(BaseModel):
6359
id: str
6460
name: str
6561
url: Optional[str] = None
6662
metadata: GalleryMetadata
67-
items: GalleryItems
63+
components: GalleryComponents
6864

6965

7066
# web request/response data models

python/packages/autogen-studio/autogenstudio/gallery/builder.py

+21-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from autogen_ext.models.openai import OpenAIChatCompletionClient
1111
from autogen_ext.models.openai._openai_client import AzureOpenAIChatCompletionClient
1212

13-
from autogenstudio.datamodel import Gallery, GalleryComponents, GalleryItems, GalleryMetadata
13+
from autogenstudio.datamodel import Gallery, GalleryComponents, GalleryMetadata
1414

1515
from . import tools as tools
1616

@@ -119,11 +119,12 @@ def build(self) -> Gallery:
119119
name=self.name,
120120
url=self.url,
121121
metadata=self.metadata,
122-
items=GalleryItems(
122+
components=GalleryComponents(
123123
teams=self.teams,
124-
components=GalleryComponents(
125-
agents=self.agents, models=self.models, tools=self.tools, terminations=self.terminations
126-
),
124+
agents=self.agents,
125+
models=self.models,
126+
tools=self.tools,
127+
terminations=self.terminations,
127128
),
128129
)
129130

@@ -195,7 +196,11 @@ def create_default_gallery() -> Gallery:
195196

196197
builder.add_termination(calc_text_term.dump_component())
197198
builder.add_termination(calc_max_term.dump_component())
198-
builder.add_termination(calc_or_term.dump_component())
199+
builder.add_termination(
200+
calc_or_term.dump_component(),
201+
label="OR Termination",
202+
description="Termination condition that ends the conversation when either a message contains 'TERMINATE' or the maximum number of messages is reached.",
203+
)
199204

200205
# Create calculator team
201206
calc_team = RoundRobinGroupChat(participants=[calc_assistant], termination_condition=calc_or_term)
@@ -227,7 +232,11 @@ def create_default_gallery() -> Gallery:
227232
model_client=base_model,
228233
headless=True,
229234
)
230-
builder.add_agent(websurfer_agent.dump_component())
235+
builder.add_agent(
236+
websurfer_agent.dump_component(),
237+
label="Web Surfer Agent",
238+
description="An agent that solves tasks by browsing the web using a headless browser.",
239+
)
231240

232241
# Create verification assistant
233242
verification_assistant = AssistantAgent(
@@ -236,7 +245,11 @@ def create_default_gallery() -> Gallery:
236245
system_message="You are a task verification assistant who is working with a web surfer agent to solve tasks. At each point, check if the task has been completed as requested by the user. If the websurfer_agent responds and the task has not yet been completed, respond with what is left to do and then say 'keep going'. If and only when the task has been completed, summarize and present a final answer that directly addresses the user task in detail and then respond with TERMINATE.",
237246
model_client=base_model,
238247
)
239-
builder.add_agent(verification_assistant.dump_component())
248+
builder.add_agent(
249+
verification_assistant.dump_component(),
250+
label="Verification Assistant",
251+
description="an agent that verifies and summarizes information",
252+
)
240253

241254
# Create user proxy
242255
web_user_proxy = UserProxyAgent(

python/packages/autogen-studio/frontend/src/components/sidebar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const Sidebar = ({ link, meta, isMobile }: SidebarProps) => {
105105
return (
106106
<div
107107
className={classNames(
108-
"flex grow flex-col gap-y-5 overflow-y-auto border-r border-secondary bg-primary",
108+
"flex grow border z-50 flex-col gap-y-5 overflow-y-auto border-r border-secondary bg-primary",
109109
"transition-all duration-300 ease-in-out",
110110
showFull ? "w-72 px-6" : "w-16 px-2"
111111
)}

python/packages/autogen-studio/frontend/src/components/views/atoms.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ export const LoadingDots = ({ size = 8 }) => {
5757
// import { Minimize2, Maximize2, ArrowsMaximize, X } from 'lucide-react';
5858
// import { Tooltip } from 'antd';
5959

60+
function safeJsonStringify(input: any): string {
61+
if (typeof input === "object" && input !== null) {
62+
return JSON.stringify(input);
63+
}
64+
return input;
65+
}
66+
6067
export const TruncatableText = memo(
6168
({
6269
content = "",
@@ -76,10 +83,12 @@ export const TruncatableText = memo(
7683
const [isExpanded, setIsExpanded] = useState(false);
7784
const [isFullscreen, setIsFullscreen] = useState(false);
7885
const threshold = isJson ? jsonThreshold : textThreshold;
86+
content = safeJsonStringify(content) + "";
7987
const shouldTruncate = content.length > threshold;
8088

81-
const toggleExpand = () => {
89+
const toggleExpand = (e: React.MouseEvent) => {
8290
setIsExpanded(!isExpanded);
91+
e.stopPropagation();
8392
};
8493

8594
const displayContent =

python/packages/autogen-studio/frontend/src/components/views/gallery/default_gallery.json

+434-436
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)