Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(builder): Updated Block Categories and colouring (#7794)

Swiftycea81bfe4e66
diff --git a/rnd/autogpt_builder/src/components/CustomNode.tsx b/rnd/autogpt_builder/src/components/CustomNode.tsx
index 511a9bd883..d0e263bf63 100644
--- a/rnd/autogpt_builder/src/components/CustomNode.tsx
+++ b/rnd/autogpt_builder/src/components/CustomNode.tsx
@@ -24,6 +24,7 @@ import NodeHandle from "./NodeHandle";
import { CustomEdgeData } from "./CustomEdge";
import { NodeGenericInputField } from "./node-input-components";
import SchemaTooltip from "./SchemaTooltip";
+import { getPrimaryCategoryColor } from "@/lib/utils";
type ParsedKey = { key: string; index?: number };
@@ -31,6 +32,7 @@ export type CustomNodeData = {
blockType: string;
title: string;
description: string;
+ categories: string[];
inputSchema: BlockIORootSchema;
outputSchema: BlockIORootSchema;
hardcodedValues: { [key: string]: any };
@@ -283,7 +285,9 @@ const CustomNode: FC<NodeProps<CustomNodeData>> = ({ data, id }) => {
onMouseEnter={handleHovered}
onMouseLeave={handleMouseLeave}
>
- <div className="mb-2 p-3 bg-gray-300/[.7] rounded-t-xl">
+ <div
+ className={`mb-2 p-3 ${getPrimaryCategoryColor(data.categories)} rounded-t-xl`}
+ >
<div className="flex items-center justify-between">
<div className="p-3 text-lg font-semibold font-roboto">
{beautifyString(
diff --git a/rnd/autogpt_builder/src/components/Flow.tsx b/rnd/autogpt_builder/src/components/Flow.tsx
index 028ed2ac39..2c0f153dc6 100644
--- a/rnd/autogpt_builder/src/components/Flow.tsx
+++ b/rnd/autogpt_builder/src/components/Flow.tsx
@@ -381,6 +381,7 @@ const FlowEditor: React.FC<{
blockType: nodeType,
title: `${nodeType} ${nodeId}`,
description: nodeSchema.description,
+ categories: nodeSchema.categories,
inputSchema: nodeSchema.inputSchema,
outputSchema: nodeSchema.outputSchema,
hardcodedValues: {},
@@ -460,6 +461,7 @@ const FlowEditor: React.FC<{
data: {
block_id: block.id,
blockType: block.name,
+ categories: block.categories,
description: block.description,
title: `${block.name} ${node.id}`,
inputSchema: block.inputSchema,
diff --git a/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx b/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx
index 736d32b36e..03bc992167 100644
--- a/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx
+++ b/rnd/autogpt_builder/src/components/edit/control/BlocksControl.tsx
@@ -15,7 +15,7 @@ import { Block } from "@/lib/autogpt-server-api";
import { PlusIcon } from "@radix-ui/react-icons";
import { IconToyBrick } from "@/components/ui/icons";
import SchemaTooltip from "@/components/SchemaTooltip";
-
+import { getPrimaryCategoryColor } from "@/lib/utils";
interface BlocksControlProps {
blocks: Block[];
addBlock: (id: string, name: string) => void;
@@ -74,7 +74,10 @@ export const BlocksControl: React.FC<BlocksControlProps> = ({
<CardContent className="p-1">
<ScrollArea className="h-[60vh]">
{filteredBlocks.map((block) => (
- <Card key={block.id} className="m-2">
+ <Card
+ key={block.id}
+ className={`m-2 ${getPrimaryCategoryColor(block.categories)}`}
+ >
<div className="flex items-center justify-between m-3">
<div className="flex-1 min-w-0 mr-2">
<span className="font-medium truncate block">
diff --git a/rnd/autogpt_builder/src/lib/autogpt-server-api/types.ts b/rnd/autogpt_builder/src/lib/autogpt-server-api/types.ts
index eef984d469..09737f8636 100644
--- a/rnd/autogpt_builder/src/lib/autogpt-server-api/types.ts
+++ b/rnd/autogpt_builder/src/lib/autogpt-server-api/types.ts
@@ -1,8 +1,15 @@
/* Mirror of autogpt_server/data/block.py:Block */
+
+export type Category = {
+ category: string;
+ description: string;
+};
+
export type Block = {
id: string;
name: string;
description: string;
+ categories: Category[];
inputSchema: BlockIORootSchema;
outputSchema: BlockIORootSchema;
};
diff --git a/rnd/autogpt_builder/src/lib/utils.ts b/rnd/autogpt_builder/src/lib/utils.ts
index 9e369c4f0d..3e7917c7a1 100644
--- a/rnd/autogpt_builder/src/lib/utils.ts
+++ b/rnd/autogpt_builder/src/lib/utils.ts
@@ -1,5 +1,6 @@
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
+import { Category } from "./autogpt-server-api/types";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
@@ -175,3 +176,21 @@ export function removeEmptyStringsAndNulls(obj: any): any {
}
return obj;
}
+
+export const categoryColorMap: Record<string, string> = {
+ AI: "bg-orange-300/[.7]",
+ SOCIAL: "bg-yellow-300/[.7]",
+ TEXT: "bg-green-300/[.7]",
+ SEARCH: "bg-blue-300/[.7]",
+ BASIC: "bg-purple-300/[.7]",
+ INPUT: "bg-cyan-300/[.7]",
+ OUTPUT: "bg-brown-300/[.7]",
+ LOGIC: "bg-teal-300/[.7]",
+};
+
+export function getPrimaryCategoryColor(categories: Category[]): string {
+ if (categories.length === 0) {
+ return "bg-gray-300/[.7]";
+ }
+ return categoryColorMap[categories[0].category] || "bg-gray-300/[.7]";
+}
diff --git a/rnd/autogpt_server/autogpt_server/blocks/agent.py b/rnd/autogpt_server/autogpt_server/blocks/agent.py
index 5f6f321402..899c561dc1 100644
--- a/rnd/autogpt_server/autogpt_server/blocks/agent.py
+++ b/rnd/autogpt_server/autogpt_server/blocks/agent.py
@@ -108,7 +108,7 @@ class AutoGPTAgentBlock(Block):
super().__init__(
id="d2e2ecd2-9ae6-422d-8dfe-ceca500ce6a6",
description="AutoGPT agent, it utilizes a Large Language Model and enabled components/tools to perform a task.",
- categories={BlockCategory.LLM},
+ categories={BlockCategory.AI},
input_schema=AutoGPTAgentBlock.Input,
output_schema=AutoGPTAgentBlock.Output,
test_input={
diff --git a/rnd/autogpt_server/autogpt_server/blocks/basic.py b/rnd/autogpt_server/autogpt_server/blocks/basic.py
index 4e84c2f1f1..174763f61c 100644
--- a/rnd/autogpt_server/autogpt_server/blocks/basic.py
+++ b/rnd/autogpt_server/autogpt_server/blocks/basic.py
@@ -158,7 +158,6 @@ class ObjectLookupBase(Block, ABC, Generic[T]):
class ObjectLookupBlock(ObjectLookupBase[Any]):
-
def __init__(self):
super().__init__(categories={BlockCategory.BASIC})
@@ -167,18 +166,16 @@ class ObjectLookupBlock(ObjectLookupBase[Any]):
class InputBlock(ObjectLookupBase[Any]):
-
def __init__(self):
- super().__init__(categories={BlockCategory.BASIC, BlockCategory.INPUT_OUTPUT})
+ super().__init__(categories={BlockCategory.BASIC, BlockCategory.INPUT})
def block_id(self) -> str:
return "c0a8e994-ebf1-4a9c-a4d8-89d09c86741b"
class OutputBlock(ObjectLookupBase[Any]):
-
def __init__(self):
- super().__init__(categories={BlockCategory.BASIC, BlockCategory.INPUT_OUTPUT})
+ super().__init__(categories={BlockCategory.BASIC, BlockCategory.OUTPUT})
def block_id(self) -> str:
return "363ae599-353e-4804-937e-b2ee3cef3da4"
diff --git a/rnd/autogpt_server/autogpt_server/blocks/llm.py b/rnd/autogpt_server/autogpt_server/blocks/llm.py
index a755d70a11..badac06cfa 100644
--- a/rnd/autogpt_server/autogpt_server/blocks/llm.py
+++ b/rnd/autogpt_server/autogpt_server/blocks/llm.py
@@ -93,7 +93,7 @@ class ObjectLlmCallBlock(Block):
super().__init__(
id="ed55ac19-356e-4243-a6cb-bc599e9b716f",
description="Call a Large Language Model (LLM) to generate formatted object based on the given prompt.",
- categories={BlockCategory.LLM},
+ categories={BlockCategory.AI},
input_schema=ObjectLlmCallBlock.Input,
output_schema=ObjectLlmCallBlock.Output,
test_input={
@@ -261,7 +261,7 @@ class TextLlmCallBlock(Block):
super().__init__(
id="1f292d4a-41a4-4977-9684-7c8d560b9f91",
description="Call a Large Language Model (LLM) to generate a string based on the given prompt.",
- categories={BlockCategory.LLM},
+ categories={BlockCategory.AI},
input_schema=TextLlmCallBlock.Input,
output_schema=TextLlmCallBlock.Output,
test_input={"prompt": "User prompt"},
@@ -307,7 +307,7 @@ class TextSummarizerBlock(Block):
super().__init__(
id="c3d4e5f6-7g8h-9i0j-1k2l-m3n4o5p6q7r8",
description="Utilize a Large Language Model (LLM) to summarize a long text.",
- categories={BlockCategory.LLM, BlockCategory.TEXT},
+ categories={BlockCategory.AI, BlockCategory.TEXT},
input_schema=TextSummarizerBlock.Input,
output_schema=TextSummarizerBlock.Output,
test_input={"text": "Lorem ipsum..." * 100},
@@ -450,7 +450,7 @@ class AdvancedLlmCallBlock(Block):
super().__init__(
id="c3d4e5f6-g7h8-i9j0-k1l2-m3n4o5p6q7r8",
description="Advanced LLM call that takes a list of messages and sends them to the language model.",
- categories={BlockCategory.LLM},
+ categories={BlockCategory.AI},
input_schema=AdvancedLlmCallBlock.Input,
output_schema=AdvancedLlmCallBlock.Output,
test_input={
@@ -495,7 +495,9 @@ class AdvancedLlmCallBlock(Block):
elif provider == "anthropic":
client = anthropic.Anthropic(api_key=api_key)
response = client.messages.create(
- model=model.value, max_tokens=max_tokens or 4096, messages=messages # type: ignore
+ model=model.value,
+ max_tokens=max_tokens or 4096,
+ messages=messages, # type: ignore
)
return response.content[0].text if response.content else ""
elif provider == "groq":
@@ -508,7 +510,9 @@ class AdvancedLlmCallBlock(Block):
return response.choices[0].message.content or ""
elif provider == "ollama":
response = ollama.chat(
- model=model.value, messages=messages, stream=False # type: ignore
+ model=model.value,
+ messages=messages,
+ stream=False, # type: ignore
)
return response["message"]["content"]
else:
diff --git a/rnd/autogpt_server/autogpt_server/data/block.py b/rnd/autogpt_server/autogpt_server/data/block.py
index 769286b7c5..12f0113d02 100644
--- a/rnd/autogpt_server/autogpt_server/data/block.py
+++ b/rnd/autogpt_server/autogpt_server/data/block.py
@@ -17,12 +17,14 @@ CompletedBlockOutput = dict[str, list[Any]] # Completed stream, collected as a
class BlockCategory(Enum):
- LLM = "Block that leverages the Large Language Model to perform a task."
+ AI = "Block that leverages AI to perform a task."
SOCIAL = "Block that interacts with social media platforms."
TEXT = "Block that processes text data."
SEARCH = "Block that searches or extracts information from the internet."
BASIC = "Block that performs basic operations."
- INPUT_OUTPUT = "Block that interacts with input/output of the graph."
+ INPUT = "Block that interacts with input of the graph."
+ OUTPUT = "Block that interacts with output of the graph."
+ LOGIC = "Programming logic to control the flow of your agent"
def dict(self) -> dict[str, str]:
return {"category": self.name, "description": self.value}
@@ -113,7 +115,6 @@ class EmptySchema(BlockSchema):
class Block(ABC, Generic[BlockSchemaInputType, BlockSchemaOutputType]):
-
def __init__(
self,
id: str = "",