Edit Role
The edit role is specialized for text editing, code modification, and content optimization, providing intelligent editing suggestions and improvements.
Configuration
Configure in config.yaml or ~/.bytebuddy/config.yaml:
models:
- name: "code-editor"
provider: "anthropic"
model: "claude-3-sonnet"
apiKey: "${ANTHROPIC_API_KEY}"
roles: ["edit"]
defaultCompletionOptions:
temperature: 0.3
maxTokens: 200000 # ⚠️ IMPORTANT: Use model's maximum supported value⚠️ IMPORTANT: Always configure maxTokens to the model's maximum supported value!
Edit roles often require significant token budgets for complete code refactoring, documentation updates, and complex edits. Setting maxTokens too low will truncate output, potentially leaving code incomplete or documentation unfinished.
Recommended maximums for common models:
- Claude 3 models: 200,000 tokens
- GPT-4 Turbo: 128,000 tokens
- GPT-4: 8,192 tokens
- Gemini Pro: 32,768 tokens
Always use the model's maximum supported value to ensure complete and usable edits.
Core Features
Code Editing
- Refactoring: Improve code structure and design
- Optimization: Enhance code performance and efficiency
- Fixing: Correct errors and bugs
- Formatting: Standardize code style
Text Editing
- Grammar Correction: Identify and fix grammar errors
- Spell Check: Find and correct spelling mistakes
- Style Optimization: Improve text style and tone
Edit Scenario Configurations
Code Refactoring
models:
- name: "refactor-editor"
provider: "anthropic"
model: "claude-3-sonnet"
apiKey: "${ANTHROPIC_API_KEY}"
roles: ["edit"]
defaultCompletionOptions:
temperature: 0.2
maxTokens: 4096Document Editing
models:
- name: "doc-editor"
provider: "openai"
model: "gpt-4"
apiKey: "${OPENAI_API_KEY}"
roles: ["edit"]
defaultCompletionOptions:
temperature: 0.4
maxTokens: 2048Quick Fix
models:
- name: "quick-fix"
provider: "openai"
model: "gpt-3.5-turbo"
apiKey: "${OPENAI_API_KEY}"
roles: ["edit"]
defaultCompletionOptions:
temperature: 0.2
maxTokens: 1024Specialized Editor Configurations
Academic Writing Editor
models:
- name: "academic-editor"
provider: "openai"
model: "gpt-4"
apiKey: "${OPENAI_API_KEY}"
roles: ["edit"]
defaultCompletionOptions:
temperature: 0.2
maxTokens: 4096Technical Documentation Editor
models:
- name: "technical-editor"
provider: "anthropic"
model: "claude-3-sonnet"
apiKey: "${ANTHROPIC_API_KEY}"
roles: ["edit"]
defaultCompletionOptions:
temperature: 0.1
maxTokens: 8192Business Writing Editor
models:
- name: "business-editor"
provider: "google"
model: "gemini-pro"
apiKey: "${GOOGLE_API_KEY}"
roles: ["edit"]
defaultCompletionOptions:
temperature: 0.3
maxTokens: 2048Creative Writing Editor
models:
- name: "creative-editor"
provider: "openai"
model: "gpt-4"
apiKey: "${OPENAI_API_KEY}"
roles: ["edit"]
defaultCompletionOptions:
temperature: 0.7
maxTokens: 3072Multi-Model Configuration
models:
- name: "code-edit"
provider: "anthropic"
model: "claude-3-sonnet"
apiKey: "${ANTHROPIC_API_KEY}"
roles: ["edit"]
defaultCompletionOptions:
temperature: 0.2
maxTokens: 4096
- name: "text-edit"
provider: "openai"
model: "gpt-4"
apiKey: "${OPENAI_API_KEY}"
roles: ["edit"]
defaultCompletionOptions:
temperature: 0.4
maxTokens: 2048
- name: "quick-edit"
provider: "openai"
model: "gpt-3.5-turbo"
apiKey: "${OPENAI_API_KEY}"
roles: ["edit"]
defaultCompletionOptions:
temperature: 0.3
maxTokens: 1024Best Practices
1. Temperature Settings
- Code Refactoring (0.1-0.3): Requires precision
- Document Optimization (0.3-0.5): Balance accuracy and creativity
- Creative Editing (0.6-0.8): More creativity
2. Token Management
- Small Changes: 512-1024 tokens
- Medium Edits: 1024-2048 tokens
- Large Refactoring: 2048-4096 tokens
- Complete Rewrite: 4096+ tokens
3. Editing Strategy
- Clearly specify editing goals
- Provide sufficient context
- Handle one major change at a time
- Validate editing results
4. Quality Control
- Use lower temperature for accuracy
- Check consistency of edits
- Preserve original intent
- Test code changes
Troubleshooting
Common Issues
Over-Editing
- Lower temperature value
- Explicitly limit edit scope
- Use more conservative prompts
Insufficient Changes
- Increase temperature
- Provide more detailed requirements
- Use more powerful models
Formatting Issues
- Specify output format
- Provide format examples
- Use dedicated formatting tools
Environment Variables
# ~/.bashrc or ~/.zshrc
export OPENAI_API_KEY="your-openai-api-key"
export ANTHROPIC_API_KEY="your-anthropic-api-key"
export GOOGLE_API_KEY="your-google-api-key"Through proper edit role configuration, you can achieve efficient and accurate code and text editing experience.