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): hide secrets from the UI and mark them as secrets in the api (#7490)

Nicholas Tindlec8b46109fed8
diff --git a/rnd/autogpt_builder/.vscode/launch.json b/rnd/autogpt_builder/.vscode/launch.json
new file mode 100644
index 0000000000..cf58704184
--- /dev/null
+++ b/rnd/autogpt_builder/.vscode/launch.json
@@ -0,0 +1,30 @@
+{
+ "version": "0.2.0",
+ "configurations": [
+
+ {
+ "name": "Next.js: debug server-side",
+ "type": "node-terminal",
+ "request": "launch",
+ "command": "yarn dev"
+ },
+ {
+ "name": "Next.js: debug client-side",
+ "type": "msedge",
+ "request": "launch",
+ "url": "http://localhost:3000"
+ },
+ {
+ "name": "Next.js: debug full stack",
+ "type": "node-terminal",
+ "request": "launch",
+ "command": "yarn dev",
+ "serverReadyAction": {
+ "pattern": "- Local:.+(https?://.+)",
+ "uriFormat": "%s",
+ "action": "debugWithEdge"
+ }
+ },
+
+ ]
+}
diff --git a/rnd/autogpt_builder/src/components/CustomNode.tsx b/rnd/autogpt_builder/src/components/CustomNode.tsx
index 12f6435e5d..1e7292408b 100644
--- a/rnd/autogpt_builder/src/components/CustomNode.tsx
+++ b/rnd/autogpt_builder/src/components/CustomNode.tsx
@@ -162,11 +162,19 @@ const CustomNode: FC<NodeProps<CustomNodeData>> = ({ data, id }) => {
return <div className="connected-input">Connected</div>;
}
- const renderClickableInput = (value: string | null = null, placeholder: string = "") => (
- <div className="clickable-input" onClick={() => handleInputClick(fullKey)}>
- {value || <i className="text-gray-500">{placeholder}</i>}
- </div>
- );
+ const renderClickableInput = (value: string | null = null, placeholder: string = "", secret: boolean = false) => {
+
+ // if secret is true, then the input field will be a password field if the value is not null
+ return secret ? (
+ <div className="clickable-input" onClick={() => handleInputClick(fullKey)}>
+ {value ? <i className="text-gray-500">********</i> : <i className="text-gray-500">{placeholder}</i>}
+ </div>
+ ) : (
+ <div className="clickable-input" onClick={() => handleInputClick(fullKey)}>
+ {value || <i className="text-gray-500">{placeholder}</i>}
+ </div>
+ )
+ };
if (schema.type === 'object' && schema.properties) {
return (
@@ -288,28 +296,42 @@ const CustomNode: FC<NodeProps<CustomNodeData>> = ({ data, id }) => {
switch (schema.type) {
case 'string':
- return schema.enum ? (
- <div key={fullKey} className="input-container">
- <select
- value={value || ''}
- onChange={(e) => handleInputChange(fullKey, e.target.value)}
- className="select-input"
- >
- <option value="">Select {displayKey}</option>
- {schema.enum.map((option: string) => (
- <option key={option} value={option}>
- {beautifyString(option)}
- </option>
- ))}
- </select>
- {error && <span className="error-message">{error}</span>}
- </div>
- ) : (
- <div key={fullKey} className="input-container">
- {renderClickableInput(value, schema.placeholder || `Enter ${displayKey}`)}
+ if (schema.enum) {
+
+ return (
+ <div key={fullKey} className="input-container">
+ <select
+ value={value || ''}
+ onChange={(e) => handleInputChange(fullKey, e.target.value)}
+ className="select-input"
+ >
+ <option value="">Select {displayKey}</option>
+ {schema.enum.map((option: string) => (
+ <option key={option} value={option}>
+ {beautifyString(option)}
+ </option>
+ ))}
+ </select>
+ {error && <span className="error-message">{error}</span>}
+ </div>
+ )
+ }
+
+ else if (schema.secret) {
+ return (<div key={fullKey} className="input-container">
+ {renderClickableInput(value, schema.placeholder || `Enter ${displayKey}`, true)}
{error && <span className="error-message">{error}</span>}
- </div>
- );
+ </div>)
+
+ }
+ else {
+ return (
+ <div key={fullKey} className="input-container">
+ {renderClickableInput(value, schema.placeholder || `Enter ${displayKey}`)}
+ {error && <span className="error-message">{error}</span>}
+ </div>
+ );
+ }
case 'boolean':
return (
<div key={fullKey} className="input-container">
diff --git a/rnd/autogpt_server/autogpt_server/data/model.py b/rnd/autogpt_server/autogpt_server/data/model.py
index fdd9340eba..56281bb28f 100644
--- a/rnd/autogpt_server/autogpt_server/data/model.py
+++ b/rnd/autogpt_server/autogpt_server/data/model.py
@@ -84,6 +84,7 @@ def SecretField(
title=title,
description=description,
placeholder=placeholder,
+ secret=True,
**kwargs,
)
@@ -95,12 +96,15 @@ def SchemaField(
title: Optional[str] = None,
description: Optional[str] = None,
placeholder: Optional[str] = None,
+ secret: bool = False,
exclude: bool = False,
**kwargs,
) -> T:
json_extra: dict[str, Any] = {}
if placeholder:
json_extra["placeholder"] = placeholder
+ if secret:
+ json_extra["secret"] = True
return Field(
default,