Elffuss BraidHub

kikocis/continue public

627d7d0d1f85 · 2.3 KiBRawPermalink
1---
2title: Edit Role
3description: Edit model role
4keywords: [edit, editing, model, role]
5sidebar_position: 3
6---
7
8It's often useful to select a different model to respond to Edit prompts than for chat prompts, as Edits are often more code-specific and may require less conversational readability.
9
10In Continue, you can add `edit` to a model's roles to specify that it can be used for Edit requests. If no edit models are specified, the selected `chat` model is used.
11
12<Tabs>
13 <Tab title="YAML">
14 Use model roles.
15 ```yaml title="config.yaml"
16 models:
17 - name: Claude 3.5 Sonnet
18 provider: anthropic
19 model: claude-3-5-sonnet-latest
20 apiKey: <YOUR_ANTHROPIC_API_KEY>
21 roles:
22 - edit
23 ```
24 </Tab>
25 <Tab title="JSON">
26 Set the `experimental.modelRoles.inlineEdit` property in `config.json`.
27 ```json title="config.json"
28 {
29 "models": {
30 "name": "Claude 3.5 Sonnet",
31 "provider": "anthropic",
32 "model": "claude-3-5-sonnet-latest",
33 "apiKey": "<YOUR_ANTHROPIC_API_KEY>"
34 },
35 "experimental": {
36 "modelRoles": {
37 "inlineEdit": "Claude 3.5 Sonnet",
38 }
39 }
40 }
41 ```
42 </Tab>
43</Tabs>
44
45Explore edit models in [the hub](https://hub.continue.dev/explore/models?roles=edit). Generally, our recommendations for Edit overlap with recommendations for Chat.
46
47## Prompt templating
48
49You can customize the prompt template used for editing code by setting the `promptTemplates.edit` property in your model configuration. Continue uses [Handlebars syntax](https://handlebarsjs.com/guide/) for templating.
50
51Available variables for the edit template:
52
53- `{{{userInput}}}` - The user's edit request/instruction
54- `{{{language}}}` - The programming language of the code
55- `{{{codeToEdit}}}` - The code that's being edited
56- `{{{prefix}}}` - Content before the edit area
57- `{{{suffix}}}` - Content after the edit area
58- `{{{supportsCompletions}}}` - Whether the model supports completions API
59- `{{{supportsPrefill}}}` - Whether the model supports prefill capability
60
61Example:
62
63```yaml
64models:
65 - name: My Custom Edit Template
66 provider: openai
67 model: gpt-4o
68 promptTemplates:
69 edit: |
70 `Here is the code before editing:
71 \`\`\`{{{language}}}
72 {{{codeToEdit}}}
73 \`\`\`
74
75 Here is the edit requested:
76 "{{{userInput}}}"
77
78 Here is the code after editing:`
79```