mirror of
https://github.com/Significant-Gravitas/Auto-GPT.git
synced 2025-01-07 03:17:23 +08:00
feat(frontend) : Add optional input support for object, array, multi-select, and select as well. (#8982)
- Resolve #8976 > Once you have checked whether this is working or not, then I will remove the optional field block. ### Changes - Updated `NodeGenericInputField` to handle additional input types: - Added support for `array` and `object` optional types. - Enhanced schema definitions for `string` optional type to include enumerations ### Testing 🔍 - Verified that the new input types function correctly within the frontend component. <img width="517" alt="Screenshot 2024-12-13 at 7 08 22 PM" src="https://github.com/user-attachments/assets/1e4b7c58-2ddc-4082-8a9e-2e11b91495e2" /> --------- Co-authored-by: Swifty <craigswift13@gmail.com> Co-authored-by: Nicholas Tindle <nicholas.tindle@agpt.co>
This commit is contained in:
parent
569222e9cd
commit
cd339b0ffc
@ -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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user