From ff26d163295b329f6dfb97578c57c9feff924d82 Mon Sep 17 00:00:00 2001 From: mq200 Date: Mon, 21 Apr 2025 09:05:14 -0700 Subject: [PATCH 1/5] add standalone template parameter in yaml model config --- core/config/yaml/models.ts | 1 + packages/config-yaml/src/schemas/models.ts | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/core/config/yaml/models.ts b/core/config/yaml/models.ts index 7b5994317..f810a2cdb 100644 --- a/core/config/yaml/models.ts +++ b/core/config/yaml/models.ts @@ -63,6 +63,7 @@ async function modelConfigToBaseLLM({ logger: llmLogger, uniqueId, title: model.name, + template: model.template, promptTemplates: model.promptTemplates, baseChatSystemMessage: model.chatOptions?.baseSystemMessage, capabilities: { diff --git a/packages/config-yaml/src/schemas/models.ts b/packages/config-yaml/src/schemas/models.ts index ad3318a15..8332d873f 100644 --- a/packages/config-yaml/src/schemas/models.ts +++ b/packages/config-yaml/src/schemas/models.ts @@ -68,6 +68,27 @@ const promptTemplatesSchema = z.object({ }); export type PromptTemplates = z.infer; +const templateSchema = z.enum([ + "llama2", + "alpaca", + "zephyr", + "phi2", + "phind", + "anthropic", + "chatml", + "none", + "openchat", + "deepseek", + "xwin-coder", + "neural-chat", + "codellama-70b", + "llava", + "gemma", + "granite", + "llama3", +]); +export type Template = z.infer; + const baseModelFields = { name: z.string(), model: z.string(), @@ -80,6 +101,7 @@ const baseModelFields = { embedOptions: embedOptionsSchema.optional(), chatOptions: chatOptionsSchema.optional(), promptTemplates: promptTemplatesSchema.optional(), + template: templateSchema.optional(), useLegacyCompletionsEndpoint: z.boolean().optional(), env: z .record(z.string(), z.union([z.string(), z.boolean(), z.number()])) From 2f8ec1ed6fc68d95ad1ac02d1069d6a28ddfafb6 Mon Sep 17 00:00:00 2001 From: mq200 Date: Wed, 23 Apr 2025 20:51:51 -0700 Subject: [PATCH 2/5] switch to promptTemplates.chat --- core/config/yaml/models.ts | 2 +- packages/config-yaml/src/schemas/models.ts | 17 ++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/config/yaml/models.ts b/core/config/yaml/models.ts index f810a2cdb..0557cad78 100644 --- a/core/config/yaml/models.ts +++ b/core/config/yaml/models.ts @@ -63,7 +63,7 @@ async function modelConfigToBaseLLM({ logger: llmLogger, uniqueId, title: model.name, - template: model.template, + template: model.promptTemplates?.chat, promptTemplates: model.promptTemplates, baseChatSystemMessage: model.chatOptions?.baseSystemMessage, capabilities: { diff --git a/packages/config-yaml/src/schemas/models.ts b/packages/config-yaml/src/schemas/models.ts index 8332d873f..692660a2b 100644 --- a/packages/config-yaml/src/schemas/models.ts +++ b/packages/config-yaml/src/schemas/models.ts @@ -61,13 +61,6 @@ export const chatOptionsSchema = z.object({ }); export type ChatOptions = z.infer; -/** Prompt templates use Handlebars syntax */ -const promptTemplatesSchema = z.object({ - apply: z.string().optional(), - edit: z.string().optional(), -}); -export type PromptTemplates = z.infer; - const templateSchema = z.enum([ "llama2", "alpaca", @@ -87,7 +80,14 @@ const templateSchema = z.enum([ "granite", "llama3", ]); -export type Template = z.infer; + +/** Prompt templates use Handlebars syntax */ +const promptTemplatesSchema = z.object({ + apply: z.string().optional(), + chat: templateSchema.optional(), + edit: z.string().optional(), +}); +export type PromptTemplates = z.infer; const baseModelFields = { name: z.string(), @@ -101,7 +101,6 @@ const baseModelFields = { embedOptions: embedOptionsSchema.optional(), chatOptions: chatOptionsSchema.optional(), promptTemplates: promptTemplatesSchema.optional(), - template: templateSchema.optional(), useLegacyCompletionsEndpoint: z.boolean().optional(), env: z .record(z.string(), z.union([z.string(), z.boolean(), z.number()])) From b7037dceec968a61cfa62a2e06b5659e9dca9de2 Mon Sep 17 00:00:00 2001 From: mq200 Date: Wed, 23 Apr 2025 22:18:03 -0700 Subject: [PATCH 3/5] update docs --- docs/docs/reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference.md b/docs/docs/reference.md index 22bc742ab..b28b8a75d 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -167,7 +167,7 @@ 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) and [`apply`](./customize/model-roles/apply.mdx#prompt-templating). +- `promptTemplates`: Can be used to override the default prompt templates for different model roles. Valid values are `chat`, [`edit`](./customize/model-roles/edit.mdx#prompt-templating) and [`apply`](./customize/model-roles/apply.mdx#prompt-templating). The `chat` property must be a valid template name, such as `llama3` or `anthropic`. - `chatOptions`: If the model includes role `chat`, these settings apply for Chat and Agent mode: - `baseSystemMessage`: Can be used to override the default system prompt. - `embedOptions`: If the model includes role `embed`, these settings apply for embeddings: From a865cc2b167ec09ed1f7fafdc49d1cfe1b1daf15 Mon Sep 17 00:00:00 2001 From: mq200 Date: Thu, 24 Apr 2025 16:42:07 -0700 Subject: [PATCH 4/5] switch to chatTemplate --- core/config/yaml/models.ts | 2 +- docs/docs/reference.md | 2 +- packages/config-yaml/src/schemas/models.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/config/yaml/models.ts b/core/config/yaml/models.ts index 0557cad78..f9d84fcd9 100644 --- a/core/config/yaml/models.ts +++ b/core/config/yaml/models.ts @@ -63,7 +63,7 @@ async function modelConfigToBaseLLM({ logger: llmLogger, uniqueId, title: model.name, - template: model.promptTemplates?.chat, + template: model.promptTemplates?.chatTemplate, promptTemplates: model.promptTemplates, baseChatSystemMessage: model.chatOptions?.baseSystemMessage, capabilities: { diff --git a/docs/docs/reference.md b/docs/docs/reference.md index b28b8a75d..62c87380f 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -167,7 +167,7 @@ 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 `chat`, [`edit`](./customize/model-roles/edit.mdx#prompt-templating) and [`apply`](./customize/model-roles/apply.mdx#prompt-templating). The `chat` property must be a valid template name, such as `llama3` or `anthropic`. +- `promptTemplates`: Can be used to override the default prompt templates for different model roles. Valid values are `chatTemplate`, [`edit`](./customize/model-roles/edit.mdx#prompt-templating) and [`apply`](./customize/model-roles/apply.mdx#prompt-templating). The `chatTemplate` property must be a valid template name, such as `llama3` or `anthropic`. - `chatOptions`: If the model includes role `chat`, these settings apply for Chat and Agent mode: - `baseSystemMessage`: Can be used to override the default system prompt. - `embedOptions`: If the model includes role `embed`, these settings apply for embeddings: diff --git a/packages/config-yaml/src/schemas/models.ts b/packages/config-yaml/src/schemas/models.ts index 692660a2b..a3e42d2c7 100644 --- a/packages/config-yaml/src/schemas/models.ts +++ b/packages/config-yaml/src/schemas/models.ts @@ -84,7 +84,7 @@ const templateSchema = z.enum([ /** Prompt templates use Handlebars syntax */ const promptTemplatesSchema = z.object({ apply: z.string().optional(), - chat: templateSchema.optional(), + chatTemplate: templateSchema.optional(), edit: z.string().optional(), }); export type PromptTemplates = z.infer; From 176c08d762a8170c7030ad34ba10a3595ae4f232 Mon Sep 17 00:00:00 2001 From: mq200 Date: Thu, 24 Apr 2025 18:01:14 -0700 Subject: [PATCH 5/5] update promptTemplates docs --- docs/docs/reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/reference.md b/docs/docs/reference.md index 6e44aa7c7..1d8790ba6 100644 --- a/docs/docs/reference.md +++ b/docs/docs/reference.md @@ -167,7 +167,7 @@ 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 `chatTemplate`, [`edit`](./customize/model-roles/edit.mdx#prompt-templating) and [`apply`](./customize/model-roles/apply.mdx#prompt-templating) and [autocomplete](./customize/model-roles/autocomplete.md#prompt-templating). The `chatTemplate` property must be a valid template name, such as `llama3` or `anthropic`. +- `promptTemplates`: Can be used to override the default prompt templates for different model roles. Valid values are `chatTemplate`, [`edit`](./customize/model-roles/edit.mdx#prompt-templating), [`apply`](./customize/model-roles/apply.mdx#prompt-templating) and [`autocomplete`](./customize/model-roles/autocomplete.md#prompt-templating). The `chatTemplate` property must be a valid template name, such as `llama3` or `anthropic`. - `chatOptions`: If the model includes role `chat`, these settings apply for Chat and Agent mode: - `baseSystemMessage`: Can be used to override the default system prompt. - `embedOptions`: If the model includes role `embed`, these settings apply for embeddings: