| title | Configuration Management |
|---|---|
| layout | default |
The chatbot uses AWS Systems Manager (SSM) Parameter Store for dynamic configuration. Update system prompts, model settings, and generation parameters without redeploying Lambda functions.
- Storage: JSON document in SSM Parameter Store (
/bedrock-chatbot/config) - Caching: 5-minute TTL for performance
- Updates: Changes take effect within 5 minutes
- Default: Created automatically during CDK deployment
The configuration is defined in /lambda/config-schema.js with the following structure:
{
"model": {
"modelId": "anthropic.claude-3-5-sonnet-20240620-v1:0",
"anthropicVersion": "bedrock-2023-05-31"
},
"prompts": {
"systemWithContext": "You are a helpful assistant. Use only the CONTEXT to answer and cite as [S#]. If unknown, say you don't know.",
"systemWithoutContext": "You are a helpful assistant. Answer clearly and concisely.",
"contextTemplate": "CONTEXT:\n{context}\n\nUSER: {prompt}"
},
"retrieval": {
"numberOfResults": 6,
"maxContextLength": 1000
},
"generation": {
"maxTokens": 800,
"temperature": 0.2,
"topP": 0.9,
"topK": 250
}
}-
modelId: The Bedrock model identifier to use for generation- Example:
anthropic.claude-3-5-sonnet-20240620-v1:0 - Other options:
anthropic.claude-3-haiku-20240307-v1:0,anthropic.claude-3-opus-20240229-v1:0
- Example:
-
anthropicVersion: The Anthropic API version- Default:
bedrock-2023-05-31
- Default:
-
enabled: Enable or disable Knowledge Base retrieval- Type:
boolean - Default:
false - When
true, the system will retrieve context from the Knowledge Base
- Type:
-
knowledgeBaseId: The Bedrock Knowledge Base ID- Type:
string - Default:
""(empty string) - Example:
"ABCDEFGH12" - Note: Config takes precedence over
KNOWLEDGE_BASE_IDenvironment variable
- Type:
-
systemWithContext: System prompt used when Knowledge Base context is available- This prompt should instruct the model on how to use the context and cite sources
- Default includes citation instructions using
[S#]format
-
systemWithoutContext: System prompt used when no Knowledge Base context is available- A more general assistant prompt for queries that don't retrieve context
-
contextTemplate: Template for formatting the user message when context is available- Use
{context}placeholder for retrieved documents - Use
{prompt}placeholder for the user's query - Default:
"CONTEXT:\n{context}\n\nUSER: {prompt}"
- Use
-
numberOfResults: Number of documents to retrieve from Knowledge Base- Default:
6 - Range: 1-100 (depending on your KB configuration)
- Default:
-
maxContextLength: Maximum length of each context snippet in characters- Default:
1000 - Helps control the total context size sent to the model
- Default:
-
maxTokens: Maximum number of tokens to generate- Default:
800 - Range: 1-4096 (model dependent)
- Default:
-
temperature: Controls randomness in generation- Default:
0.2 - Range: 0.0 (deterministic) to 1.0 (creative)
- Default:
-
topP: Nucleus sampling parameter- Default:
0.9 - Range: 0.0 to 1.0
- Default:
-
topK: Top-K sampling parameter- Default:
250 - Range: 0-500
- Default:
The project includes a Node.js CLI for configuration management:
# View configuration
npm run cli config get
# Update from file
npm run cli config update my-config.json
# Set specific value
npm run cli config set generation.temperature 0.7
# Validate file
npm run cli config validate my-config.json
# Backup
npm run cli config backup backup.json
# Reset to defaults
npm run cli config resetCONFIG_PARAM_NAME- SSM parameter name (default:/bedrock-chatbot/config)AWS_REGION- AWS regionAWS_PROFILE- AWS profile
- Go to Systems Manager → Parameter Store
- Find
/bedrock-chatbot/config - Click Edit → Modify JSON → Save
Changes take effect within 5 minutes.
npm run cli config set knowledgeBase.enabled true
npm run cli config set knowledgeBase.knowledgeBaseId "YOUR_KB_ID"npm run cli config set knowledgeBase.enabled falsenpm run cli config set model.modelId "anthropic.claude-3-haiku-20240307-v1:0"npm run cli config set generation.temperature 0.7
npm run cli config set generation.maxTokens 1500Edit a config file and update:
{
"prompts": {
"systemWithContext": "You are a technical advisor. Use CONTEXT and cite as [S#].",
"systemWithoutContext": "You are a technical advisor.",
"contextTemplate": "Reference:\n{context}\n\nQuestion: {prompt}"
}
}npm run cli config update my-prompts.jsonCheck CloudWatch Logs for:
Configuration loaded from SSM- SuccessFailed to load config from SSM, using defaults- Fallback active
Changes not applying?
- Wait 5 minutes for cache to expire
- Check CloudWatch Logs for errors
JSON validation errors?
npm run cli config validate my-config.jsonAccess denied?
- Verify Lambda IAM role has
ssm:GetParameterpermission - Check parameter exists:
/bedrock-chatbot/config