Skip to content

Commit 2ac9e7e

Browse files
feat: Add environment variable support for AI agent configuration (#2956)
1 parent 7a185df commit 2ac9e7e

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

Parse-Dashboard/server.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ module.exports = (options) => {
3939
const configUserPassword = options.userPassword || process.env.PARSE_DASHBOARD_USER_PASSWORD;
4040
const configSSLKey = options.sslKey || process.env.PARSE_DASHBOARD_SSL_KEY;
4141
const configSSLCert = options.sslCert || process.env.PARSE_DASHBOARD_SSL_CERT;
42+
const configAgent = options.agent || process.env.PARSE_DASHBOARD_AGENT;
4243

4344
function handleSIGs(server) {
4445
const signals = {
@@ -83,6 +84,21 @@ module.exports = (options) => {
8384
}
8485
];
8586
}
87+
// Add agent configuration from environment variables
88+
if (configAgent) {
89+
// If it's already an object (from JS config), use it directly
90+
if (typeof configAgent === 'object') {
91+
configFromCLI.data.agent = configAgent;
92+
} else {
93+
// Otherwise, try to parse it as JSON
94+
try {
95+
configFromCLI.data.agent = JSON.parse(configAgent);
96+
} catch (error) {
97+
console.error('Failed to parse PARSE_DASHBOARD_AGENT:', error.message);
98+
process.exit(1);
99+
}
100+
}
101+
}
86102
} else if (!configServerURL && !configMasterKey && !configAppName) {
87103
configFile = path.join(__dirname, 'parse-dashboard-config.json');
88104
}

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ PARSE_DASHBOARD_SSL_KEY: "sslKey"
213213
PARSE_DASHBOARD_SSL_CERT: "sslCert"
214214
PARSE_DASHBOARD_CONFIG: undefined // Only for reference, it must not exist
215215
PARSE_DASHBOARD_COOKIE_SESSION_SECRET: undefined // set the cookie session secret, defaults to a random string. Use this option if you want sessions to work across multiple servers, or across restarts
216+
PARSE_DASHBOARD_AGENT: undefined // JSON string containing the full agent configuration with models array
216217
217218
```
218219

@@ -525,8 +526,8 @@ Parse.Cloud.define('deleteAccount', async (req) => {
525526

526527
Parse Dashboard can cache its resources such as bundles in the browser, so that opening the dashboard in another tab does not reload the dashboard resources from the server but from the local browser cache. Caching only starts after login in the dashboard.
527528

528-
| Parameter | Type | Optional | Default | Example | Description |
529-
|-----------------------|---------|----------|---------|---------|-----------------------------------------------------------------------------------------------------------------------------------------|
529+
| Parameter | Type | Optional | Default | Example | Description |
530+
|-----------------------|---------|----------|---------|---------|----------------------------------------------------------------------------------------------------------------|
530531
| `enableResourceCache` | Boolean | yes | `false` | `true` | Enables caching of dashboard resources in the browser for faster dashboard loading in additional browser tabs. |
531532

532533

@@ -1294,14 +1295,14 @@ To configure the AI agent for your dashboard, you need to add the `agent` config
12941295
}
12951296
```
12961297

1297-
| Parameter | Type | Required | Description |
1298-
|-----------------------------|--------|----------|--------------------------------------------------------------------------------|
1299-
| `agent` | Object | Yes | The AI agent configuration object. |
1300-
| `agent.models` | Array | Yes | Array of AI model configurations available to the agent. |
1301-
| `agent.models[*].name` | String | Yes | The display name for the model (e.g., `ChatGPT 4.1`). |
1302-
| `agent.models[*].provider` | String | Yes | The AI provider identifier (e.g., "openai"). |
1303-
| `agent.models[*].model` | String | Yes | The specific model name from the provider (e.g., `gpt-4.1`). |
1304-
| `agent.models[*].apiKey` | String | Yes | The API key for authenticating with the AI provider. |
1298+
| Parameter | Type | Required | Description |
1299+
|----------------------------|--------|----------|-------------------------------------------------------------------------------------------------------------------------------------|
1300+
| `agent` | Object | Yes | The AI agent configuration object. When using the environment variable, provide the complete agent configuration as a JSON string. |
1301+
| `agent.models` | Array | Yes | Array of AI model configurations available to the agent. |
1302+
| `agent.models[*].name` | String | Yes | The display name for the model (e.g., `ChatGPT 4.1`). |
1303+
| `agent.models[*].provider` | String | Yes | The AI provider identifier (e.g., "openai"). |
1304+
| `agent.models[*].model` | String | Yes | The specific model name from the provider (e.g., `gpt-4.1`). |
1305+
| `agent.models[*].apiKey` | String | Yes | The API key for authenticating with the AI provider. |
13051306

13061307
The agent will use the configured models to process natural language commands and perform database operations using the master key from your app configuration.
13071308

0 commit comments

Comments
 (0)