Apply Role
When editing code, Chat and Edit model output often doesn't clearly align with existing code. A model with the apply
role is used to generate a more precise diff to apply changes to a file.
Generally speaking, models proficient in chat and edit can also be used for applying code.
Recommended Apply Models
Morph Fast Apply
Morph is a specialized model designed for fast and accurate code application. It's optimized to take original code and generated code, then create a precise diff that can be applied to your file.
- YAML
models:
- name: Morph Fast Apply
provider: openai
model: morph-v0
apiKey: YOUR_MORPH_API_KEY
apiBase: https://api.morphllm.com/v1/
roles:
- apply
promptTemplates:
apply: "<code>{{{ original_code }}}</code>\n<update>{{{ new_code }}}</update>"
You can sign up for a free Morph API key at https://morphllm.com/dashboard.
Other Models
You can also use general-purpose models like GPT-4o or Claude for the Apply role, though specialized models like Morph are optimized for this specific task.
For more detailed information about the Apply feature, see the Apply documentation.
Explore apply models in the hub.