Skip to content

Commit ad71131

Browse files
refactor: Address review feedback for agent env var support
- Change configAgentConfig to configAgent for naming consistency - Handle both JS config objects and JSON strings properly - Remove separate env var chapter, integrate into existing table - Add environment variable column to AI Agent configuration table 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f208bd7 commit ad71131

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

Parse-Dashboard/server.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +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 configAgentConfig = options.agentConfig || process.env.PARSE_DASHBOARD_AGENT_CONFIG;
42+
const configAgent = options.agent || process.env.PARSE_DASHBOARD_AGENT_CONFIG;
4343

4444
function handleSIGs(server) {
4545
const signals = {
@@ -85,12 +85,18 @@ module.exports = (options) => {
8585
];
8686
}
8787
// Add agent configuration from environment variables
88-
if (configAgentConfig) {
89-
try {
90-
configFromCLI.data.agent = JSON.parse(configAgentConfig);
91-
} catch (error) {
92-
console.error('Failed to parse PARSE_DASHBOARD_AGENT_CONFIG:', error.message);
93-
process.exit(1);
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_CONFIG:', error.message);
98+
process.exit(1);
99+
}
94100
}
95101
}
96102
} else if (!configServerURL && !configMasterKey && !configAppName) {

README.md

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,28 +1295,22 @@ To configure the AI agent for your dashboard, you need to add the `agent` config
12951295
}
12961296
```
12971297

1298-
| Parameter | Type | Required | Description |
1299-
|-----------------------------|--------|----------|--------------------------------------------------------------------------------|
1300-
| `agent` | Object | Yes | The AI agent configuration object. |
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. |
1298+
| Parameter | Type | Required | Description | Environment Variable |
1299+
|-----------------------------|--------|----------|--------------------------------------------------------------------------------|-----------------------|
1300+
| `agent` | Object | Yes | The AI agent configuration object. | `PARSE_DASHBOARD_AGENT_CONFIG` |
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. | - |
13061306

1307-
The agent will use the configured models to process natural language commands and perform database operations using the master key from your app configuration.
1308-
1309-
### Environment Variables
1310-
1311-
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.
1312-
1313-
Set the `PARSE_DASHBOARD_AGENT_CONFIG` environment variable with a JSON string containing the full agent configuration:
1314-
1315-
```
1316-
PARSE_DASHBOARD_AGENT_CONFIG='{"models":[{"name":"ChatGPT 4.1","provider":"openai","model":"gpt-4.1","apiKey":"YOUR_API_KEY"}]}'
1317-
```
1307+
> [!Note]
1308+
> When using the `PARSE_DASHBOARD_AGENT_CONFIG` environment variable, provide the complete agent configuration as a JSON string. For example:
1309+
> ```bash
1310+
> PARSE_DASHBOARD_AGENT_CONFIG='{"models":[{"name":"ChatGPT 4.1","provider":"openai","model":"gpt-4.1","apiKey":"YOUR_API_KEY"}]}'
1311+
> ```
13181312
1319-
This supports the same multi-model configuration structure as the JSON config file, allowing you to define multiple AI models in the array.
1313+
The agent will use the configured models to process natural language commands and perform database operations using the master key from your app configuration.
13201314
13211315
### Providers
13221316

0 commit comments

Comments
 (0)