Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add v1 Drag and Drop Team Composition to AGS #4609

Merged
merged 17 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
ToolCallMessage,
ToolCallResultMessage,
)

from ....state import MagenticOneOrchestratorState
from .._base_group_chat_manager import BaseGroupChatManager
from .._events import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@
import aiofiles
import yaml
from autogen_agentchat.agents import AssistantAgent, UserProxyAgent
from autogen_agentchat.conditions import MaxMessageTermination, StopMessageTermination, TextMentionTermination
from autogen_agentchat.teams import RoundRobinGroupChat, SelectorGroupChat, MagenticOneGroupChat
from autogen_agentchat.conditions import (
ExternalTermination,
HandoffTermination,
MaxMessageTermination,
SourceMatchTermination,
StopMessageTermination,
TextMentionTermination,
TimeoutTermination,
TokenUsageTermination,
)
from autogen_agentchat.teams import MagenticOneGroupChat, RoundRobinGroupChat, SelectorGroupChat
from autogen_core.components.tools import FunctionTool
from autogen_ext.agents.web_surfer import MultimodalWebSurfer
from autogen_ext.agents.file_surfer import FileSurfer
from autogen_ext.agents.magentic_one import MagenticOneCoderAgent
from autogen_ext.agents.web_surfer import MultimodalWebSurfer
from autogen_ext.models import OpenAIChatCompletionClient

from ..datamodel.types import (
Expand All @@ -38,7 +47,17 @@
AgentComponent = Union[AssistantAgent, MultimodalWebSurfer, UserProxyAgent, FileSurfer, MagenticOneCoderAgent]
ModelComponent = Union[OpenAIChatCompletionClient]
ToolComponent = Union[FunctionTool] # Will grow with more tool types
TerminationComponent = Union[MaxMessageTermination, StopMessageTermination, TextMentionTermination]
TerminationComponent = Union[
MaxMessageTermination,
StopMessageTermination,
TextMentionTermination,
TimeoutTermination,
ExternalTermination,
TokenUsageTermination,
HandoffTermination,
SourceMatchTermination,
StopMessageTermination,
]

Component = Union[TeamComponent, AgentComponent, ModelComponent, ToolComponent, TerminationComponent]

Expand Down
2 changes: 1 addition & 1 deletion python/packages/autogen-studio/autogenstudio/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION = "0.4.0.dev38"
VERSION = "0.4.0.dev39"
__version__ = VERSION
APP_NAME = "autogenstudio"
1 change: 1 addition & 0 deletions python/packages/autogen-studio/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"dependencies": {
"@dagrejs/dagre": "^1.1.4",
"@dnd-kit/core": "^6.2.0",
"@headlessui/react": "^2.2.0",
"@heroicons/react": "^2.0.18",
"@mdx-js/react": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ContentHeader = ({
</button>

{/* Desktop Sidebar Toggle - Hidden on Mobile */}
<div className="hidden md:block">
{/* <div className="hidden md:block">
<Tooltip title={isExpanded ? "Close Sidebar" : "Open Sidebar"}>
<button
onClick={() => setSidebarState({ isExpanded: !isExpanded })}
Expand All @@ -65,7 +65,7 @@ const ContentHeader = ({
)}
</button>
</Tooltip>
</div>
</div> */}

<div className="flex flex-1 gap-x-4 self-stretch lg:gap-x-6">
{/* Breadcrumbs */}
Expand Down
13 changes: 11 additions & 2 deletions python/packages/autogen-studio/frontend/src/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Footer from "./footer";
import "antd/dist/reset.css";
import SideBar from "./sidebar";
import ContentHeader from "./contentheader";
import { ConfigProvider, theme } from "antd";

const classNames = (...classes: (string | undefined | boolean)[]) => {
return classes.filter(Boolean).join(" ");
Expand Down Expand Up @@ -91,13 +92,21 @@ const Layout = ({
>
{showHeader && (
<ContentHeader
title={title}
isMobileMenuOpen={isMobileMenuOpen}
onMobileMenuToggle={() => setIsMobileMenuOpen(!isMobileMenuOpen)}
/>
)}

<main className="flex-1 p-2 text-primary">{children}</main>
<ConfigProvider
theme={{
algorithm:
darkMode === "dark"
? theme.darkAlgorithm
: theme.defaultAlgorithm,
}}
>
<main className="flex-1 p-2 text-primary">{children}</main>
</ConfigProvider>

<Footer />
</div>
Expand Down
104 changes: 76 additions & 28 deletions python/packages/autogen-studio/frontend/src/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import React from "react";
import { Link } from "gatsby";
import { useConfigStore } from "../hooks/store";
import { Tooltip } from "antd";
import { Settings, MessagesSquare } from "lucide-react";
import {
Settings,
MessagesSquare,
Blocks,
Bot,
PanelLeftClose,
PanelLeftOpen,
} from "lucide-react";
import Icon from "./icons";

interface INavItem {
Expand All @@ -23,6 +30,12 @@ const navigation: INavItem[] = [
icon: MessagesSquare,
breadcrumbs: [{ name: "Playground", href: "/", current: true }],
},
{
name: "Agent Teams",
href: "/build",
icon: Bot,
breadcrumbs: [{ name: "Build", href: "/build", current: true }],
},
];

const classNames = (...classes: (string | undefined | boolean)[]) => {
Expand Down Expand Up @@ -51,9 +64,9 @@ const Sidebar = ({ link, meta, isMobile }: SidebarProps) => {
const showFull = isMobile || isExpanded;

const handleNavClick = (item: INavItem) => {
if (!isExpanded) {
setSidebarState({ isExpanded: true });
}
// if (!isExpanded) {
// setSidebarState({ isExpanded: true });
// }
setHeader({
title: item.name,
breadcrumbs: item.breadcrumbs,
Expand Down Expand Up @@ -165,11 +178,53 @@ const Sidebar = ({ link, meta, isMobile }: SidebarProps) => {
<li
className={classNames(
"mt-auto -mx-2 mb-4",
!showFull && "flex justify-center"
!showFull && "flex flex-col items-center gap-1"
)}
>
{!showFull && !isMobile ? (
<Tooltip title="Settings" placement="right">
<>
<Tooltip title="Settings" placement="right">
<Link
to="/settings"
onClick={() =>
setHeader({
title: "Settings",
breadcrumbs: [
{
name: "Settings",
href: "/settings",
current: true,
},
],
})
}
className="group flex gap-x-3 rounded-md p-2 text-sm font-medium text-primary hover:text-accent hover:bg-secondary justify-center"
>
<Settings className="h-6 w-6 shrink-0 text-secondary group-hover:text-accent" />
</Link>
</Tooltip>
<div className="hidden md:block">
<Tooltip
title={isExpanded ? "Close Sidebar" : "Open Sidebar"}
placement="right"
>
<button
onClick={() =>
setSidebarState({ isExpanded: !isExpanded })
}
className="p-2 rounded-md hover:bg-secondary hover:text-accent text-secondary transition-colors focus:outline-none focus:ring-2 focus:ring-accent focus:ring-opacity-50"
>
{isExpanded ? (
<PanelLeftClose strokeWidth={1.5} className="h-6 w-6" />
) : (
<PanelLeftOpen strokeWidth={1.5} className="h-6 w-6" />
)}
</button>
</Tooltip>
</div>
</>
) : (
<div className="flex items-center gap-2">
<Link
to="/settings"
onClick={() =>
Expand All @@ -180,31 +235,24 @@ const Sidebar = ({ link, meta, isMobile }: SidebarProps) => {
],
})
}
className={classNames(
"group flex gap-x-3 rounded-md p-2 text-sm font-medium",
"text-primary hover:text-accent hover:bg-secondary",
!showFull && "justify-center"
)}
className="group flex flex-1 gap-x-3 rounded-md p-2 text-sm font-medium text-primary hover:text-accent hover:bg-secondary"
>
<Settings className="h-6 w-6 shrink-0 text-secondary group-hover:text-accent" />
{showFull && "Settings"}
</Link>
</Tooltip>
) : (
<Link
to="/settings"
onClick={() =>
setHeader({
title: "Settings",
breadcrumbs: [
{ name: "Settings", href: "/settings", current: true },
],
})
}
className="group flex gap-x-3 rounded-md p-2 text-sm font-medium text-primary hover:text-accent hover:bg-secondary"
>
<Settings className="h-6 w-6 shrink-0 text-secondary group-hover:text-accent" />
{showFull && "Settings"}
</Link>
<div className="hidden md:block">
<button
onClick={() => setSidebarState({ isExpanded: !isExpanded })}
className="p-2 rounded-md hover:bg-secondary hover:text-accent text-secondary transition-colors focus:outline-none focus:ring-2 focus:ring-accent focus:ring-opacity-50"
>
{isExpanded ? (
<PanelLeftClose strokeWidth={1.5} className="h-6 w-6" />
) : (
<PanelLeftOpen strokeWidth={1.5} className="h-6 w-6" />
)}
</button>
</div>
</div>
)}
</li>
</ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export interface Session extends DBModel {
team_id?: number;
}

export interface SessionRuns {
runs: Run[];
}

export interface BaseConfig {
component_type: string;
version?: string;
Expand All @@ -114,11 +118,17 @@ export type ModelTypes = "OpenAIChatCompletionClient";
export type AgentTypes =
| "AssistantAgent"
| "CodingAssistantAgent"
| "UserProxyAgent"
| "MultimodalWebSurfer"
| "FileSurfer"
| "MagenticOneCoderAgent";

export type TeamTypes = "RoundRobinGroupChat" | "SelectorGroupChat" | "MagenticOneGroupChat";
export type ToolTypes = "PythonFunction";

export type TeamTypes =
| "RoundRobinGroupChat"
| "SelectorGroupChat"
| "MagenticOneGroupChat";

// class ComponentType(str, Enum):
// TEAM = "team"
Expand All @@ -129,7 +139,9 @@ export type TeamTypes = "RoundRobinGroupChat" | "SelectorGroupChat" | "MagenticO
export type TerminationTypes =
| "MaxMessageTermination"
| "StopMessageTermination"
| "TextMentionTermination";
| "TextMentionTermination"
| "TimeoutTermination"
| "CombinationTermination";

export type ComponentTypes =
| "team"
Expand All @@ -138,6 +150,13 @@ export type ComponentTypes =
| "tool"
| "termination";

export type ComponentConfigTypes =
| TeamConfig
| AgentConfig
| ModelConfig
| ToolConfig
| TerminationConfig;

export interface ModelConfig extends BaseConfig {
model: string;
model_type: ModelTypes;
Expand All @@ -149,7 +168,7 @@ export interface ToolConfig extends BaseConfig {
name: string;
description: string;
content: string;
tool_type: string;
tool_type: ToolTypes;
}
export interface AgentConfig extends BaseConfig {
name: string;
Expand All @@ -171,7 +190,7 @@ export interface TeamConfig extends BaseConfig {
team_type: TeamTypes;
model_client?: ModelConfig;
termination_condition?: TerminationConfig;
selector_config?: string;
selector_prompt?: string;
}

export interface Team extends DBModel {
Expand All @@ -187,6 +206,7 @@ export interface TeamResult {
export interface Run {
id: string;
created_at: string;
updated_at?: string;
status: RunStatus;
task: AgentMessageConfig;
team_result: TeamResult | null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
ReactFlowProvider,
NodeChange,
applyNodeChanges,
MiniMap,
} from "@xyflow/react";
import Dagre from "@dagrejs/dagre";
import "@xyflow/react/dist/style.css";
Expand Down Expand Up @@ -564,6 +565,7 @@ const AgentFlow: React.FC<AgentFlowProps> = ({ teamConfig, run }) => {

<ReactFlow {...reactFlowProps}>
{settings.showGrid && <Background />}
{settings.showMiniMap && <MiniMap />}
<div className="absolute top-0 right-0 z-50">
<AgentFlowToolbar {...toolbarProps} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
MessageSquare,
LayoutGrid,
RotateCcw,
MapIcon,
} from "lucide-react";
import { useConfigStore } from "../../../../../hooks/store";

Expand Down Expand Up @@ -55,6 +56,12 @@ export const AgentFlowToolbar: React.FC<AgentFlowToolbarProps> = ({
// icon: <MessageSquare size={16} />,
// onClick: toggleSetting("showMessages"),
// },
{
key: "miniMap",
label: "Mini Map",
icon: <MapIcon size={16} />,
onClick: toggleSetting("showMiniMap"),
},
{
type: "divider",
},
Expand Down
Loading
Loading