diff --git a/docs/docs/customize/model-roles/apply.mdx b/docs/docs/customize/model-roles/apply.mdx index 1ecace184..b60a83505 100644 --- a/docs/docs/customize/model-roles/apply.mdx +++ b/docs/docs/customize/model-roles/apply.mdx @@ -13,3 +13,27 @@ When editing code, Chat and Edit model output often doesn't clearly align with e Generally speaking, models proficient in chat and edit can also be used for applying code. Explore apply models in [the hub](https://hub.continue.dev/explore/models?roles=apply). + +## Prompt templating + +You can customize the prompt template used for applying code changes by setting the `promptTemplates.apply` property in your model configuration. Continue uses [Handlebars syntax](https://handlebarsjs.com/guide/) for templating. + +Available variables for the apply template: + +- `{{{original_code}}}` - The original code before changes +- `{{{new_code}}}` - The new code after changes + +Example: + +```yaml +models: + - name: My Custom Applier + provider: anthropic + model: claude-3-5-sonnet-latest + promptTemplates: + apply: | + Original: {{{original_code}}} + New: {{{new_code}}} + + Please generate the final code without any markers or explanations. +``` diff --git a/docs/docs/customize/model-roles/chat.mdx b/docs/docs/customize/model-roles/chat.mdx index aca683782..4d92d2c6e 100644 --- a/docs/docs/customize/model-roles/chat.mdx +++ b/docs/docs/customize/model-roles/chat.mdx @@ -363,3 +363,26 @@ If your local machine can run a 16B parameter model, then we recommend running D ## Other experiences There are many more models and providers you can use with Chat beyond those mentioned above. Read more [here](../model-roles/chat.mdx) + +## Prompt templating + +You can customize the system prompt used for chat interactions by setting the `promptTemplates.baseSystemPrompt` property in your model configuration. Continue uses [Handlebars syntax](https://handlebarsjs.com/guide/) for templating. + +Available variables for the chat template: + +- `{{{history}}}` - The conversation history +- `{{{system_message}}}` - The default system message (if provided) + +Example: + +```yaml +models: + - name: My Custom Chat Model + provider: openai + model: gpt-4o + promptTemplates: + baseSystemPrompt: | + You are an expert coding assistant specialized in JavaScript development. + Always provide code examples when explaining concepts. + {{{system_message}}} +``` diff --git a/docs/docs/customize/model-roles/edit.mdx b/docs/docs/customize/model-roles/edit.mdx index de817ed42..078e1564e 100644 --- a/docs/docs/customize/model-roles/edit.mdx +++ b/docs/docs/customize/model-roles/edit.mdx @@ -46,3 +46,33 @@ In Continue, you can add `edit` to a model's roles to specify that it can be use Explore edit models in [the hub](https://hub.continue.dev/explore/models?roles=edit). Generally, our recommendations for Edit overlap with recommendations for Chat. + +## Prompt templating + +You 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. + +Available variables for the edit template: + +- `{{{userInput}}}` - The user's edit request/instruction +- `{{{language}}}` - The programming language of the code +- `{{{codeToEdit}}}` - The code that's being edited +- `{{{prefix}}}` - Content before the edit area +- `{{{suffix}}}` - Content after the edit area +- `{{{supportsCompletions}}}` - Whether the model supports completions API +- `{{{supportsPrefill}}}` - Whether the model supports prefill capability + +Example: + +````yaml +models: + - name: My Custom Editor + provider: openai + model: gpt-4o + promptTemplates: + edit: | + Please modify this code: + ```{{{language}}} + {{{codeToEdit}}} + ``` + According to this request: {{{userInput}}} +```` diff --git a/docs/docs/reference.md b/docs/docs/reference.md index b9ae84846..9e1af2d1a 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -145,15 +145,11 @@ The `models` section defines the language models used in your configuration. Mod - `apiBase`: Can be used to override the default API base that is specified per model - `roles`: An array specifying the roles this model can fulfill, such as `chat`, `autocomplete`, `embed`, `rerank`, `edit`, `apply`, `summarize`. The default value is `[chat, edit, apply, summarize]`. Note that the `summarize` role is not currently used. - `capabilities`: Array of strings denoting model capabilities, which will overwrite Continue's autodetection based on provider and model. Supported capabilities include `tool_use` and `image_input`. +- `promptTemplates`: Can be used to override the default prompt templates for different model roles. Valid values are [`edit`](./customize/model-roles/edit.mdx#prompt-templating), [`apply`](./customize/model-roles/apply.mdx#prompt-templating), and [`baseSystemPrompt`](./customize/model-roles/chat.mdx#prompt-templating) (used to override the system prompt in Chat and Agent). Handlebars syntax can be used to insert variables in your prompt. - `embedOptions`: If the model includes role `embed`, these settings apply for embeddings: - - `maxChunkSize`: Maximum tokens per document chunk. Minimum is 128 tokens. - `maxBatchSize`: Maximum number of chunks per request. Minimum is 1 chunk. - - `defaultCompletionOptions`: Default completion options for model settings. - - **Properties:** - - `contextLength`: Maximum context length of the model, typically in tokens. - `maxTokens`: Maximum number of tokens to generate in a completion. - `temperature`: Controls the randomness of the completion. Values range from `0.0` (deterministic) to `1.0` (random). @@ -161,11 +157,7 @@ The `models` section defines the language models used in your configuration. Mod - `topK`: Maximum number of tokens considered at each step. - `stop`: An array of stop tokens that will terminate the completion. - `n`: Number of completions to generate. - - `requestOptions`: HTTP request options specific to the model. - - **Properties:** - - `timeout`: Timeout for each request to the language model. - `verifySsl`: Whether to verify SSL certificates for requests. - `caBundlePath`: Path to a custom CA bundle for HTTP requests. @@ -178,7 +170,7 @@ The `models` section defines the language models used in your configuration. Mod - `key`: Path to the client certificate key file. - `passphrase`: Optional passphrase for the client certificate key file. -#### Example: +#### Example ```yaml title="config.yaml" models: