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(frontend) : Add optional input support for object, array, multi-select, and select as well. (#8982)

Abhimanyu Yadavcd339b0ffc04
diff --git a/autogpt_platform/frontend/src/components/node-input-components.tsx b/autogpt_platform/frontend/src/components/node-input-components.tsx
index f92ea1dcb2..04999420fb 100644
--- a/autogpt_platform/frontend/src/components/node-input-components.tsx
+++ b/autogpt_platform/frontend/src/components/node-input-components.tsx
@@ -299,7 +299,13 @@ export const NodeGenericInputField: FC<{
return (
<NodeStringInput
selfKey={propKey}
- schema={{ ...propSchema, type: "string" } as BlockIOStringSubSchema}
+ schema={
+ {
+ ...propSchema,
+ type: "string",
+ enum: (propSchema.anyOf[0] as BlockIOStringSubSchema).enum,
+ } as BlockIOStringSubSchema
+ }
value={currentValue}
error={errors[propKey]}
className={className}
@@ -315,7 +321,12 @@ export const NodeGenericInputField: FC<{
return (
<NodeNumberInput
selfKey={propKey}
- schema={{ ...propSchema, type: "integer" } as BlockIONumberSubSchema}
+ schema={
+ {
+ ...propSchema,
+ type: "integer",
+ } as BlockIONumberSubSchema
+ }
value={currentValue}
error={errors[propKey]}
className={className}
@@ -323,6 +334,48 @@ export const NodeGenericInputField: FC<{
handleInputChange={handleInputChange}
/>
);
+ } else if (types.includes("array") && types.includes("null")) {
+ return (
+ <NodeArrayInput
+ nodeId={nodeId}
+ selfKey={propKey}
+ schema={
+ {
+ ...propSchema,
+ type: "array",
+ items: (propSchema.anyOf[0] as BlockIOArraySubSchema).items,
+ } as BlockIOArraySubSchema
+ }
+ entries={currentValue}
+ errors={errors}
+ className={className}
+ displayName={displayName}
+ connections={connections}
+ handleInputChange={handleInputChange}
+ handleInputClick={handleInputClick}
+ />
+ );
+ } else if (types.includes("object") && types.includes("null")) {
+ return (
+ <NodeKeyValueInput
+ nodeId={nodeId}
+ selfKey={propKey}
+ schema={
+ {
+ ...propSchema,
+ type: "object",
+ additionalProperties: (propSchema.anyOf[0] as BlockIOKVSubSchema)
+ .additionalProperties,
+ } as BlockIOKVSubSchema
+ }
+ entries={currentValue}
+ errors={errors}
+ className={className}
+ displayName={displayName}
+ connections={connections}
+ handleInputChange={handleInputChange}
+ />
+ );
}
}