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.

fix(frontend/builder): Fix key-value pair input for any non-string types (#9826)

Zamil Majdyc0ee71fb2748
diff --git a/autogpt_platform/frontend/src/components/node-input-components.tsx b/autogpt_platform/frontend/src/components/node-input-components.tsx
index 7985d97ae2..b9d7d1acd9 100644
--- a/autogpt_platform/frontend/src/components/node-input-components.tsx
+++ b/autogpt_platform/frontend/src/components/node-input-components.tsx
@@ -772,14 +772,16 @@ const NodeKeyValueInput: FC<{
);
}
+ const isNumberType =
+ schema.additionalProperties &&
+ ["number", "integer"].includes(schema.additionalProperties.type);
+
function convertValueType(value: string): string | number | null {
- if (
- !schema.additionalProperties ||
- schema.additionalProperties.type == "string"
- )
- return value;
- if (!value) return null;
- return Number(value);
+ if (isNumberType) {
+ const numValue = Number(value);
+ return !isNaN(numValue) ? numValue : null;
+ }
+ return value;
}
function getEntryKey(key: string): string {
@@ -825,7 +827,7 @@ const NodeKeyValueInput: FC<{
}
/>
<LocalValuedInput
- type="text"
+ type={isNumberType ? "number" : "text"}
placeholder="Value"
value={value ?? ""}
onChange={(e) =>