Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions launchdarkly/ai_config_strands/.env.example
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# Shared LaunchDarkly Configuration
LD_SERVER_KEY='add your SDK server key'
LD_SERVER_KEY='add your LaunchDarkly SDK server key'

# LaunchDarkly API Access Token (for management operations)
# Get this from Account Settings → Authorization in LaunchDarkly dashboard
LD_API_KEY='add your LaunchDarkly API Access token server key'

# Shared AI Config identifier for multi-agent system
# Change this value if you want to create a new AI config
LD_AI_CONFIG_ID='multi-agent-llm-prompt'
LD_AI_CONFIG_ID='multi-agent-strands'

# LaunchDarkly project key
LD_PROJECT_KEY='add your project name'
LD_PROJECT_KEY='add your LaunchDarkly project name'

# Agent-specific roles for context targeting
TEACHER_ORCHESTRATOR_ROLE=teacher-orchestrator
Expand Down
25 changes: 25 additions & 0 deletions launchdarkly/ai_config_strands/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Environment variables
.env

# Virtual environments
venv/
bootstrap/venv/

# Python cache
__pycache__/
*.pyc
*.pyo
*.pyd
.Python

# IDE files
.vscode/
.idea/
*.swp
*.swo

# OS files
.DS_Store
Thumbs.db

repl_state/
55 changes: 48 additions & 7 deletions launchdarkly/ai_config_strands/bootstrap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,22 @@ export LD_PROJECT_KEY="your-project-key"
```

### 3. Run the Script

#### Recommended: Skip Existing Resources
```bash
python create_ai_config.py --skip-existing
```

#### Other Options
```bash
# Normal mode (may encounter conflicts)
python create_ai_config.py

# Force targeting updates (use with caution)
python create_ai_config.py --skip-existing --force-targeting

# Show help
python create_ai_config.py --help
```

## 📋 What the Script Does
Expand Down Expand Up @@ -70,25 +84,46 @@ Example:

## 🔧 Troubleshooting

### Common Issues
### Fixed Issues (Latest Version)

The script has been updated to handle common errors:

1. **Resources already exist**: Gracefully handles existing segments, AI model configs, AI configs, and variations
2. **YAML syntax error**: Fixed malformed YAML in the manifest file
3. **Targeting rule conflicts**: Smart conflict detection to avoid duplicate targeting rules
4. **Internal service errors**: Improved error handling and resource existence checking

### Common Issues & Solutions

**Missing Environment Variables**
```
❌ LD_API_KEY environment variable not set
```
Solution: Set your LaunchDarkly API key
Solution: Set your LaunchDarkly API key or add to `.env` file

**"Already exists" errors**
```
❌ Segment already exists
```
Solution: Use `--skip-existing` flag

**Variation Key Mismatch**
```
❌ Variation key 'computer_science_assistant' not found in variation map
```
Solution: Check that segment names match variation keys (use hyphens, not underscores)

**Duplicate Rules**
**Duplicate Targeting Rules**
```
❌ Failed to update targeting: 400 - new rule is exact duplicate
```
Solution: Delete existing AI Config or modify targeting rules
Solution: Script now automatically detects and skips duplicate rules

**Internal Service Errors**
```
❌ 500 Internal Server Error
```
Solution: Usually resolved by improved error handling in latest version

### Debug Mode
Add detailed logging by modifying the script or checking the console output for step-by-step progress.
Expand All @@ -103,11 +138,17 @@ The `ai_config_manifest.yaml` defines:

## 🔄 Re-running the Script

The script handles existing resources:
- **Segments**: Skips if already exist
The script intelligently handles existing resources:
- **Segments**: Skips if already exist (with `--skip-existing`)
- **AI Config**: Skips if already exists
- **Variations**: Skips if already exist
- **Targeting**: Updates existing rules
- **Targeting**: Detects and avoids duplicate rules

### Command Line Options

- `--skip-existing`: Skip creating resources that already exist (recommended)
- `--force-targeting`: Force targeting rule updates even if rules exist (use with caution)
- `--help`: Show all available options

## 🛡️ Security

Expand Down
40 changes: 23 additions & 17 deletions launchdarkly/ai_config_strands/bootstrap/ai_config_manifest.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project:
key: "mp-webinar-test-1"
key: "gcasilva"
environment:
- key: production
segment:
Expand Down Expand Up @@ -52,84 +52,90 @@ project:
contextKind: "user"
negate: false
ai-config:
key: "multi-agent-llm-prompt"
key: "multi-agent-strands-agentcore-2"
description: "Multi-agent LLM Prompt"
ai-model-configs:
- name: "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
key: "Bedrock.us.anthropic.claude-3-7-sonnet-20250219-v1-0"
- name: "us.anthropic.claude-3-5-sonnet-20241022-v2:0"
key: "Bedrock.us.anthropic.claude-3-5-sonnet-20241022-v2-0"
costPerInputToken: 0.000003
costPerOutputToken: 0.000015
id: "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
id: "us.anthropic.claude-3-5-sonnet-20241022-v2:0"
provider: "Bedrock:Anthropic"
- name: "us.amazon.nova-pro-v1:0"
key: "Bedrock.us.amazon.nova-pro-v1-0"
costPerInputToken: 0.0000008
costPerOutputToken: 0.0000032
id: "us.amazon.nova-pro-v1:0"
provider: "Bedrock:Amazon"
variations:
- key: teacher-orchestrator
system_prompt_source: fallback_prompts/teacher_orchestrator_fallback_prompt.txt
model_config_key: Bedrock.amazon.nova-pro-v1:0
model_config_key: Bedrock.us.amazon.nova-pro-v1-0
parameters:
custom_parameters: '{"maxTokens":4096,"temperature":0.9,"topP":0.9}'
- key: computer-science-assistant
system_prompt_source: fallback_prompts/computer_science_assistant_fallback_prompt.txt
model_config_key: Bedrock.us.anthropic.claude-3-7-sonnet-20250219-v1-0
model_config_key: Bedrock.us.anthropic.claude-3-5-sonnet-20241022-v2-0
parameters:
custom_parameters: '{"maxTokens":4096,"temperature":0.9,"topP":0.9}'
- key: math-assistant
system_prompt_source: fallback_prompts/math_assistant_fallback_prompt.txt
model_config_key: Bedrock.us.anthropic.claude-3-7-sonnet-20250219-v1-0
model_config_key: Bedrock.us.anthropic.claude-3-5-sonnet-20241022-v2-0
parameters:
custom_parameters: '{"maxTokens":4096,"temperature":0.9,"topP":0.9}'
- key: language-assistant
system_prompt_source: fallback_prompts/language_assistant_fallback_prompt.txt
model_config_key: Bedrock.us.anthropic.claude-3-5-sonnet-20241022-v2:0
model_config_key: Bedrock.us.anthropic.claude-3-5-sonnet-20241022-v2-0
parameters:
custom_parameters: '{"maxTokens":4096,"temperature":0.9,"topP":0.9}'
- key: english-assistant
system_prompt_source: fallback_prompts/english_assistant_fallback_prompt.txt
model_config_key: Bedrock.us.anthropic.claude-3-5-sonnet-20241022-v2:0
model_config_key: Bedrock.us.anthropic.claude-3-5-sonnet-20241022-v2-0
parameters:
custom_parameters: '{"maxTokens":4096,"temperature":0.9,"topP":0.9}'
- key: general-assistant
system_prompt_source: fallback_prompts/general_assistant_fallback_prompt.txt
model_config_key: Bedrock.amazon.nova-pro-v1:0
model_config_key: Bedrock.us.amazon.nova-pro-v1-0
parameters:
custom_parameters: '{"maxTokens":4096,"temperature":0.9,"topP":0.9}'
rules:
- clauses:
- attribute": "segmentMatch"
- attribute: "segmentMatch"
negate: false
op: "segmentMatch"
values:
- "agent-teacher-orchestrator"
trackEvents: false
- clauses:
- attribute": "segmentMatch"
- attribute: "segmentMatch"
negate: false
op: "segmentMatch"
values:
- "agent-computer-science-assistant"
trackEvents: false
- clauses:
- attribute": "segmentMatch"
- attribute: "segmentMatch"
negate: false
op: "segmentMatch"
values:
- "agent-math-assistant"
trackEvents: false
- clauses:
- attribute": "segmentMatch"
- attribute: "segmentMatch"
negate: false
op: "segmentMatch"
values:
- "agent-english-assistant"
trackEvents: false
- clauses:
- attribute": "segmentMatch"
- attribute: "segmentMatch"
negate: false
op: "segmentMatch"
values:
- "agent-language-assistant"
trackEvents: false
- clauses:
- attribute": "segmentMatch"
- attribute: "segmentMatch"
negate: false
op: "segmentMatch"
values:
Expand Down
Loading