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, server): Add advanced block inputs (#7934)

Krzysztof Czerwinski09951fed4b1a
diff --git a/rnd/autogpt_builder/src/components/CustomNode.tsx b/rnd/autogpt_builder/src/components/CustomNode.tsx
index e0d58d5b2f..6120c0207c 100644
--- a/rnd/autogpt_builder/src/components/CustomNode.tsx
+++ b/rnd/autogpt_builder/src/components/CustomNode.tsx
@@ -118,12 +118,6 @@ export function CustomNode({ data, id, width, height }: NodeProps<CustomNode>) {
setIsAdvancedOpen(checked);
};
- const hasOptionalFields =
- data.inputSchema &&
- Object.keys(data.inputSchema.properties).some((key) => {
- return !data.inputSchema.required?.includes(key);
- });
-
const generateOutputHandles = (schema: BlockIORootSchema) => {
if (!schema?.properties) return null;
const keys = Object.keys(schema.properties);
@@ -368,11 +362,20 @@ export function CustomNode({ data, id, width, height }: NodeProps<CustomNode>) {
const errorClass =
hasConfigErrors || hasOutputError ? "border-red-500 border-2" : "";
+
const statusClass =
hasConfigErrors || hasOutputError
? "failed"
: (data.status?.toLowerCase() ?? "");
+ const hasAdvancedFields =
+ data.inputSchema &&
+ Object.entries(data.inputSchema.properties).some(([key, value]) => {
+ return (
+ value.advanced === true && !data.inputSchema.required?.includes(key)
+ );
+ });
+
return (
<div
className={`${blockClasses} ${errorClass} ${statusClass}`}
@@ -421,8 +424,12 @@ export function CustomNode({ data, id, width, height }: NodeProps<CustomNode>) {
([propKey, propSchema]) => {
const isRequired = data.inputSchema.required?.includes(propKey);
const isConnected = isHandleConnected(propKey);
+ const isAdvanced = propSchema.advanced;
return (
- (isRequired || isAdvancedOpen || isConnected) && (
+ (isRequired ||
+ isAdvancedOpen ||
+ isConnected ||
+ !isAdvanced) && (
<div key={propKey} onMouseOver={() => {}}>
<NodeHandle
keyName={propKey}
@@ -479,7 +486,7 @@ export function CustomNode({ data, id, width, height }: NodeProps<CustomNode>) {
<div className="mt-2.5 flex items-center pb-4 pl-4">
<Switch checked={isOutputOpen} onCheckedChange={toggleOutput} />
<span className="m-1 mr-4">Output</span>
- {hasOptionalFields && (
+ {hasAdvancedFields && (
<>
<Switch onCheckedChange={toggleAdvancedSettings} />
<span className="m-1">Advanced</span>
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 aa527bea4e..20948f4870 100644
--- a/rnd/autogpt_builder/src/lib/autogpt-server-api/types.ts
+++ b/rnd/autogpt_builder/src/lib/autogpt-server-api/types.ts
@@ -39,6 +39,7 @@ export type BlockIOSubSchemaMeta = {
title?: string;
description?: string;
placeholder?: string;
+ advanced?: boolean;
};
export type BlockIOObjectSubSchema = BlockIOSubSchemaMeta & {
diff --git a/rnd/autogpt_server/autogpt_server/data/model.py b/rnd/autogpt_server/autogpt_server/data/model.py
index 3a7892184e..0c877a4fe7 100644
--- a/rnd/autogpt_server/autogpt_server/data/model.py
+++ b/rnd/autogpt_server/autogpt_server/data/model.py
@@ -109,6 +109,7 @@ def SchemaField(
title: Optional[str] = None,
description: Optional[str] = None,
placeholder: Optional[str] = None,
+ advanced: Optional[bool] = None,
secret: bool = False,
exclude: bool = False,
**kwargs,
@@ -118,6 +119,8 @@ def SchemaField(
json_extra["placeholder"] = placeholder
if secret:
json_extra["secret"] = True
+ if advanced:
+ json_extra["advanced"] = True
return Field(
default,