Skip to content

Commit 4864ab7

Browse files
feat: Add environment variable support for AI agent configuration
This commit adds support for configuring the AI agent via environment variables, following the same pattern used for other dashboard configurations. Two configuration methods are supported: 1. Full JSON configuration via PARSE_DASHBOARD_AGENT_CONFIG - Allows complex multi-model setups - Accepts a JSON string with the complete agent configuration 2. Individual environment variables for simple single-model setups: - PARSE_DASHBOARD_AGENT_MODEL_NAME - PARSE_DASHBOARD_AGENT_MODEL_PROVIDER - PARSE_DASHBOARD_AGENT_MODEL - PARSE_DASHBOARD_AGENT_API_KEY This enhancement makes it easier to deploy Parse Dashboard in containerized environments and improves security by allowing API keys to be stored as environment variables rather than in configuration files. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 192df4f commit 4864ab7

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

Parse-Dashboard/server.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ 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 configAgentConfig = options.agentConfig || process.env.PARSE_DASHBOARD_AGENT_CONFIG;
43+
const configAgentModelName = options.agentModelName || process.env.PARSE_DASHBOARD_AGENT_MODEL_NAME;
44+
const configAgentModelProvider = options.agentModelProvider || process.env.PARSE_DASHBOARD_AGENT_MODEL_PROVIDER;
45+
const configAgentModel = options.agentModel || process.env.PARSE_DASHBOARD_AGENT_MODEL;
46+
const configAgentApiKey = options.agentApiKey || process.env.PARSE_DASHBOARD_AGENT_API_KEY;
4247

4348
function handleSIGs(server) {
4449
const signals = {
@@ -83,6 +88,24 @@ module.exports = (options) => {
8388
}
8489
];
8590
}
91+
// Add agent configuration from environment variables
92+
if (configAgentConfig) {
93+
try {
94+
configFromCLI.data.agent = JSON.parse(configAgentConfig);
95+
} catch (error) {
96+
console.error('Failed to parse PARSE_DASHBOARD_AGENT_CONFIG:', error.message);
97+
process.exit(1);
98+
}
99+
} else if (configAgentModelName && configAgentModelProvider && configAgentModel && configAgentApiKey) {
100+
configFromCLI.data.agent = {
101+
models: [{
102+
name: configAgentModelName,
103+
provider: configAgentModelProvider,
104+
model: configAgentModel,
105+
apiKey: configAgentApiKey
106+
}]
107+
};
108+
}
86109
} else if (!configServerURL && !configMasterKey && !configAppName) {
87110
configFile = path.join(__dirname, 'parse-dashboard-config.json');
88111
}

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,11 @@ 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_CONFIG: undefined // JSON string containing the full agent configuration with models array
217+
PARSE_DASHBOARD_AGENT_MODEL_NAME: undefined // Display name for the AI model (e.g. "ChatGPT 4.1")
218+
PARSE_DASHBOARD_AGENT_MODEL_PROVIDER: undefined // AI provider identifier (e.g. "openai")
219+
PARSE_DASHBOARD_AGENT_MODEL: undefined // Specific model name from the provider (e.g. "gpt-4.1")
220+
PARSE_DASHBOARD_AGENT_API_KEY: undefined // API key for authenticating with the AI provider
216221
217222
```
218223

@@ -1305,6 +1310,32 @@ To configure the AI agent for your dashboard, you need to add the `agent` config
13051310

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

1313+
### Environment Variables
1314+
1315+
You can also configure the AI agent using environment variables, which is useful for containerized deployments or when you want to avoid storing API keys in configuration files.
1316+
1317+
#### Option 1: Full JSON Configuration
1318+
1319+
For complex setups with multiple models, you can provide the entire agent configuration as a JSON string:
1320+
1321+
```
1322+
PARSE_DASHBOARD_AGENT_CONFIG='{"models":[{"name":"ChatGPT 4.1","provider":"openai","model":"gpt-4.1","apiKey":"YOUR_API_KEY"}]}'
1323+
```
1324+
1325+
#### Option 2: Individual Environment Variables
1326+
1327+
For simpler setups with a single model, you can use individual environment variables:
1328+
1329+
```
1330+
PARSE_DASHBOARD_AGENT_MODEL_NAME="ChatGPT 4.1"
1331+
PARSE_DASHBOARD_AGENT_MODEL_PROVIDER="openai"
1332+
PARSE_DASHBOARD_AGENT_MODEL="gpt-4.1"
1333+
PARSE_DASHBOARD_AGENT_API_KEY="YOUR_API_KEY"
1334+
```
1335+
1336+
> [!Note]
1337+
> If both `PARSE_DASHBOARD_AGENT_CONFIG` and individual variables are provided, `PARSE_DASHBOARD_AGENT_CONFIG` takes precedence.
1338+
13081339
### Providers
13091340

13101341
> [!Note]

0 commit comments

Comments
 (0)