Merge branch 'main' into allow-skip-ollama-onboarding

This commit is contained in:
Patrick Erichsen 2025-04-10 09:10:19 -07:00
commit 48bbf39a53
30 changed files with 510 additions and 117 deletions

View file

@ -31,6 +31,62 @@ jobs:
if: steps.root-cache.outputs.cache-hit != 'true'
run: npm ci
install-config-yaml:
needs: install-root
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Install config-yaml dependencies
if: steps.config-yaml-cache.outputs.cache-hit != 'true'
run: |
cd packages/config-yaml
npm ci
config-yaml-checks:
needs: install-config-yaml
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.os }}-root-node-modules-${{ hashFiles('package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build and check config-yaml
run: |
cd packages/config-yaml
npx tsc --noEmit
# Tests are currently failing, commenting out for now
# npm test
npm run build
install-core:
needs: install-root
runs-on: ubuntu-latest
@ -60,7 +116,7 @@ jobs:
npm ci
core-checks:
needs: install-core
needs: [install-core, install-config-yaml]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@ -81,6 +137,17 @@ jobs:
path: core/node_modules
key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build config-yaml
run: |
cd packages/config-yaml
npm run build
- name: Type check and lint
run: |
cd core
@ -90,7 +157,7 @@ jobs:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
install-gui:
needs: [install-root, install-core]
needs: [install-root, install-core, install-config-yaml]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@ -115,6 +182,17 @@ jobs:
path: gui/node_modules
key: ${{ runner.os }}-gui-node-modules-${{ hashFiles('gui/package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build config-yaml
run: |
cd packages/config-yaml
npm run build
- name: Install gui dependencies
if: steps.gui-cache.outputs.cache-hit != 'true'
run: |
@ -147,13 +225,24 @@ jobs:
path: gui/node_modules
key: ${{ runner.os }}-gui-node-modules-${{ hashFiles('gui/package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build config-yaml
run: |
cd packages/config-yaml
npm run build
- name: Type check
run: |
cd gui
npx tsc --noEmit
binary-checks:
needs: [install-root, install-core]
needs: [install-root, install-core, install-config-yaml]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@ -178,6 +267,17 @@ jobs:
path: binary/node_modules
key: ${{ runner.os }}-binary-node-modules-${{ hashFiles('binary/package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build config-yaml
run: |
cd packages/config-yaml
npm run build
- name: Install binary dependencies
if: steps.binary-cache.outputs.cache-hit != 'true'
run: |
@ -190,7 +290,7 @@ jobs:
npx tsc --noEmit
install-vscode:
needs: [install-root, install-core]
needs: [install-root, install-core, install-config-yaml]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@ -215,6 +315,17 @@ jobs:
path: extensions/vscode/node_modules
key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build config-yaml
run: |
cd packages/config-yaml
npm run build
- name: Install vscode dependencies
if: steps.vscode-cache.outputs.cache-hit != 'true'
run: |
@ -249,6 +360,17 @@ jobs:
path: extensions/vscode/node_modules
key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build config-yaml
run: |
cd packages/config-yaml
npm run build
- name: Type check and lint
run: |
cd extensions/vscode
@ -256,7 +378,7 @@ jobs:
npm run lint
core-tests:
needs: install-core
needs: [install-core, install-config-yaml]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@ -270,6 +392,17 @@ jobs:
path: core/node_modules
key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build config-yaml
run: |
cd packages/config-yaml
npm run build
- name: Run core tests
run: |
cd core
@ -285,7 +418,7 @@ jobs:
vscode-get-test-file-matrix:
runs-on: ubuntu-latest
needs: [install-root, install-vscode]
needs: [install-root, install-vscode, install-config-yaml]
outputs:
test_file_matrix: ${{ steps.vscode-get-test-file-matrix.outputs.test_file_matrix }}
steps:
@ -297,6 +430,17 @@ jobs:
path: extensions/vscode/node_modules
key: ${{ runner.os }}-vscode-node-modules-${{ hashFiles('extensions/vscode/package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build config-yaml
run: |
cd packages/config-yaml
npm run build
- name: Get test files
id: vscode-get-test-file-matrix
run: |
@ -320,7 +464,7 @@ jobs:
vscode-package-extension:
runs-on: ubuntu-latest
needs: [install-vscode, install-core]
needs: [install-vscode, install-core, install-config-yaml]
steps:
- uses: actions/checkout@v4
@ -340,6 +484,17 @@ jobs:
path: core/node_modules
key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build config-yaml
run: |
cd packages/config-yaml
npm run build
- name: Package extension
run: |
cd extensions/vscode
@ -353,7 +508,7 @@ jobs:
vscode-download-e2e-dependencies:
runs-on: ubuntu-latest
needs: [install-vscode, install-core]
needs: [install-vscode, install-core, install-config-yaml]
steps:
- uses: actions/checkout@v4
@ -373,6 +528,17 @@ jobs:
path: extensions/vscode/e2e/storage
key: ${{ runner.os }}-vscode-storage-${{ hashFiles('extensions/vscode/package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build config-yaml
run: |
cd packages/config-yaml
npm run build
- name: Download Dependencies
if: steps.storage-cache.outputs.cache-hit != 'true'
run: |
@ -394,6 +560,7 @@ jobs:
vscode-package-extension,
install-vscode,
install-core,
install-config-yaml,
]
runs-on: ubuntu-latest
# Tests requiring secrets need approval from maintainers
@ -434,6 +601,17 @@ jobs:
name: vscode-e2e-dependencies
path: extensions/vscode/e2e/storage
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build config-yaml
run: |
cd packages/config-yaml
npm run build
- name: Fix VSCode binary permissions
run: |
chmod +x extensions/vscode/e2e/storage/VSCode-linux-x64/code
@ -476,7 +654,7 @@ jobs:
path: extensions/vscode/e2e/storage/screenshots
gui-tests:
needs: [install-gui, install-core]
needs: [install-gui, install-core, install-config-yaml]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@ -496,6 +674,17 @@ jobs:
path: core/node_modules
key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build config-yaml
run: |
cd packages/config-yaml
npm run build
- name: Install GUI dependencies
if: steps.gui-cache.outputs.cache-hit != 'true'
run: cd gui && npm ci
@ -508,7 +697,7 @@ jobs:
npm test
jetbrains-tests:
needs: [install-root, core-checks]
needs: [install-root, core-checks, install-config-yaml]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
@ -517,6 +706,17 @@ jobs:
path: core/node_modules
key: ${{ runner.os }}-core-node-modules-${{ hashFiles('core/package-lock.json') }}
- uses: actions/cache@v4
id: config-yaml-cache
with:
path: packages/config-yaml/node_modules
key: ${{ runner.os }}-config-yaml-node-modules-${{ hashFiles('packages/config-yaml/package-lock.json') }}
- name: Build config-yaml
run: |
cd packages/config-yaml
npm run build
- name: Setup Java
uses: actions/setup-java@v4.5.0
with:
@ -627,6 +827,8 @@ jobs:
- vscode-e2e-tests
- gui-tests
- jetbrains-tests
- config-yaml-checks
- install-config-yaml
steps:
- name: Decide whether the needed jobs succeeded or failed

View file

@ -34,13 +34,18 @@ export function ctxItemToRifWithContents(
): RangeInFileWithContents {
let startLine = 0;
let endLine = 0;
let adjustLines = linesOffByOne ? 1 : 0;
const nameSplit = item.name.split("(");
if (nameSplit.length > 1) {
const lines = nameSplit[1].split(")")[0].split("-");
startLine = Number.parseInt(lines[0], 10) - (linesOffByOne ? 1 : 0);
endLine = Number.parseInt(lines[1], 10) - (linesOffByOne ? 1 : 0);
startLine = Number.parseInt(lines[0], 10);
if (startLine === 0) {
adjustLines = 0; // safety to make sure doesn't go negative
}
startLine -= adjustLines;
endLine = Number.parseInt(lines[1], 10) - adjustLines;
}
const rif: RangeInFileWithContents = {

View file

@ -70,7 +70,11 @@ import { localPathToUri } from "../util/pathToUri";
import { getSystemPromptDotFile } from "./getSystemPromptDotFile";
import { modifyAnyConfigWithSharedConfig } from "./sharedConfig";
import { getModelByRole, isSupportedLanceDbCpuTargetForLinux } from "./util";
import {
getModelByRole,
isSupportedLanceDbCpuTargetForLinux,
serializePromptTemplates,
} from "./util";
import { validateConfig } from "./validation.js";
export function resolveSerializedConfig(
@ -607,8 +611,9 @@ function llmToSerializedModelDescription(llm: ILLM): ModelDescription {
template: llm.template,
completionOptions: llm.completionOptions,
systemMessage: llm.systemMessage,
baseChatSystemMessage: llm.baseChatSystemMessage,
requestOptions: llm.requestOptions,
promptTemplates: llm.promptTemplates as any,
promptTemplates: serializePromptTemplates(llm.promptTemplates),
capabilities: llm.capabilities,
roles: llm.roles,
configurationStatus: llm.getConfigurationStatus(),

45
core/config/util.test.ts Normal file
View file

@ -0,0 +1,45 @@
import { PromptTemplate } from "..";
import { serializePromptTemplates } from "./util";
describe("serializePromptTemplates", () => {
it("should return undefined for undefined input", () => {
expect(serializePromptTemplates(undefined)).toBeUndefined();
});
it("should convert function templates to empty strings", () => {
const functionTemplate: PromptTemplate = () => "Generated template";
const templates: Record<string, PromptTemplate> = {
template1: functionTemplate,
};
const result = serializePromptTemplates(templates);
expect(result).toEqual({ template1: "" });
});
it("should pass through string templates unchanged", () => {
const templates: Record<string, PromptTemplate> = {
template1: "This is a static template",
template2: "Another static template",
};
const result = serializePromptTemplates(templates);
expect(result).toEqual(templates);
});
it("should handle mixed template types", () => {
const functionTemplate: PromptTemplate = () => "Generated template";
const templates: Record<string, PromptTemplate> = {
function: functionTemplate,
string: "This is a static template",
};
const result = serializePromptTemplates(templates);
expect(result).toEqual({
function: "",
string: "This is a static template",
});
});
});

View file

@ -7,6 +7,7 @@ import {
IDE,
ILLM,
ModelDescription,
PromptTemplate,
} from "../";
import { GlobalContext } from "../util/GlobalContext";
import { editConfigFile } from "../util/paths";
@ -169,3 +170,22 @@ async function showUnsupportedCpuToast(ide: IDE) {
);
}
}
/**
* This is required because users are only able to define prompt templates as a
* string, while internally we also allow prompt templates to be functions
* @param templates
* @returns
*/
export function serializePromptTemplates(
templates: Record<string, PromptTemplate> | undefined,
): Record<string, string> | undefined {
if (!templates) return undefined;
return Object.fromEntries(
Object.entries(templates).map(([key, template]) => {
const serialized = typeof template === "function" ? "" : template;
return [key, serialized];
}),
);
}

View file

@ -66,6 +66,7 @@ async function modelConfigToBaseLLM({
systemMessage: config.systemMessage,
rules: config.rules,
promptTemplates: model.promptTemplates,
baseChatSystemMessage: model.chatOptions?.baseSystemMessage,
capabilities: {
tools: model.capabilities?.includes("tool_use"),
uploadImage: model.capabilities?.includes("image_input"),

44
core/index.d.ts vendored
View file

@ -77,39 +77,19 @@ export type PromptTemplateFunction = (
export type PromptTemplate = string | PromptTemplateFunction;
export interface ILLM extends LLMOptions {
type RequiredLLMOptions =
| "uniqueId"
| "contextLength"
| "embeddingId"
| "maxEmbeddingChunkSize"
| "maxEmbeddingBatchSize"
| "completionOptions";
export interface ILLM
extends Omit<LLMOptions, RequiredLLMOptions>,
Required<Pick<LLMOptions, RequiredLLMOptions>> {
get providerName(): string;
uniqueId: string;
model: string;
title?: string;
systemMessage?: string;
contextLength: number;
maxStopWords?: number;
completionOptions: CompletionOptions;
requestOptions?: RequestOptions;
promptTemplates?: Record<string, PromptTemplate>;
templateMessages?: (messages: ChatMessage[]) => string;
llmLogger?: ILLMLogger;
llmRequestHook?: (model: string, prompt: string) => any;
apiKey?: string;
apiBase?: string;
cacheBehavior?: CacheBehavior;
capabilities?: ModelCapability;
roles?: ModelRole[];
deployment?: string;
apiVersion?: string;
apiType?: string;
region?: string;
projectId?: string;
// Embedding options
embeddingId: string;
maxEmbeddingChunkSize: number;
maxEmbeddingBatchSize: number;
complete(
prompt: string,
signal: AbortSignal,
@ -580,6 +560,7 @@ export interface LLMOptions {
title?: string;
uniqueId?: string;
systemMessage?: string;
baseChatSystemMessage?: string;
contextLength?: number;
maxStopWords?: number;
completionOptions?: CompletionOptions;
@ -1059,6 +1040,7 @@ export interface ModelDescription {
template?: TemplateType;
completionOptions?: BaseCompletionOptions;
systemMessage?: string;
baseChatSystemMessage?: string;
requestOptions?: RequestOptions;
promptTemplates?: { [key: string]: string };
cacheBehavior?: CacheBehavior;

View file

@ -1,14 +1,41 @@
import { ChatHistoryItem, ChatMessage, MessagePart } from "../";
import { normalizeToMessageParts } from "../util/messageContent";
const DEFAULT_SYSTEM_MESSAGE = `<important_rules>
Always include the language and file name in the info string when you write code blocks. If you are editing "src/main.py" for example, your code block should start with '\`\`\`python src/main.py'.
const DEFAULT_SYSTEM_MESSAGE = `\
<important_rules>
Always include the language and file name in the info string when you write code blocks.
If you are editing "src/main.py" for example, your code block should start with '\`\`\`python src/main.py'
When addressing code modification requests, present a concise code snippet that
emphasizes only the necessary changes and uses abbreviated placeholders for
unmodified sections. For instance:
\`\`\`typescript /path/to/file
// ... rest of code here ...
{{ modified code here }}
// ... rest of code here ...
{{ another modification }}
// ... rest of code here ...
\`\`\`
Since users have access to their complete file, they prefer reading only the
relevant modifications. It's perfectly acceptable to omit unmodified portions
at the beginning, middle, or end of files using these "lazy" comments. Only
provide the complete file when explicitly requested. Include a concise explanation
of changes unless the user specifically asks for code only.
</important_rules>`;
const CANCELED_TOOL_CALL_MESSAGE =
"This tool call was cancelled by the user. You should clarify next steps, as they don't wish for you to use this tool.";
export function constructMessages(history: ChatHistoryItem[]): ChatMessage[] {
export function constructMessages(
history: ChatHistoryItem[],
baseChatSystemMessage: string | undefined,
): ChatMessage[] {
const filteredHistory = history.filter(
(item) => item.message.role !== "system",
);
@ -16,7 +43,7 @@ export function constructMessages(history: ChatHistoryItem[]): ChatMessage[] {
msgs.push({
role: "system",
content: DEFAULT_SYSTEM_MESSAGE,
content: baseChatSystemMessage ?? DEFAULT_SYSTEM_MESSAGE,
});
for (let i = 0; i < filteredHistory.length; i++) {

View file

@ -127,6 +127,7 @@ export abstract class BaseLLM implements ILLM {
title?: string;
systemMessage?: string;
baseChatSystemMessage?: string;
contextLength: number;
maxStopWords?: number | undefined;
completionOptions: CompletionOptions;
@ -195,6 +196,7 @@ export abstract class BaseLLM implements ILLM {
this.title = options.title;
this.uniqueId = options.uniqueId ?? "None";
this.systemMessage = options.systemMessage;
this.baseChatSystemMessage = options.baseChatSystemMessage;
this.contextLength =
options.contextLength ?? llmInfo?.contextLength ?? DEFAULT_CONTEXT_LENGTH;
this.maxStopWords = options.maxStopWords ?? this.maxStopWords;

33
core/package-lock.json generated
View file

@ -13,7 +13,7 @@
"@aws-sdk/client-sagemaker-runtime": "^3.777.0",
"@aws-sdk/credential-providers": "^3.778.0",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "^1.0.77",
"@continuedev/config-yaml": "file:../packages/config-yaml",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.8",
"@continuedev/openai-adapters": "^1.0.18",
@ -108,6 +108,27 @@
"node": ">=20.11.0"
}
},
"../packages/config-yaml": {
"name": "@continuedev/config-yaml",
"version": "1.0.78",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/config-types": "^1.0.14",
"yaml": "^2.6.1",
"zod": "^3.24.2"
},
"bin": {
"config-yaml": "dist/cli.js"
},
"devDependencies": {
"@types/jest": "^29.5.14",
"@types/node": "^20.0.0",
"cross-env": "^7.0.3",
"jest": "^29.7.0",
"ts-jest": "^29.2.3",
"ts-node": "^10.9.2"
}
},
"node_modules/@75lb/deep-merge": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.2.tgz",
@ -2977,14 +2998,8 @@
}
},
"node_modules/@continuedev/config-yaml": {
"version": "1.0.77",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.77.tgz",
"integrity": "sha512-Vke6jp4bENjJc9fO1tavOnbYXRmmSIEzNhYeQ6DzZVl92+8rWwdO6zhbrK0r4FGjHnH0cJgyK/q0zX9/l+6asw==",
"dependencies": {
"@continuedev/config-types": "^1.0.14",
"yaml": "^2.6.1",
"zod": "^3.24.2"
}
"resolved": "../packages/config-yaml",
"link": true
},
"node_modules/@continuedev/fetch": {
"version": "1.0.4",

View file

@ -47,7 +47,7 @@
"@aws-sdk/client-sagemaker-runtime": "^3.777.0",
"@aws-sdk/credential-providers": "^3.778.0",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "^1.0.77",
"@continuedev/config-yaml": "file:../packages/config-yaml",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.8",
"@continuedev/openai-adapters": "^1.0.18",

View file

@ -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 Apply Template
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.
```

View file

@ -46,3 +46,37 @@ In Continue, you can add `edit` to a model's roles to specify that it can be use
</Tabs>
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 Edit Template
provider: openai
model: gpt-4o
promptTemplates:
edit: |
`Here is the code before editing:
\`\`\`{{{language}}}
{{{codeToEdit}}}
\`\`\`
Here is the edit requested:
"{{{userInput}}}"
Here is the code after editing:`
```

View file

@ -51,8 +51,8 @@ func = get_registry().get("openai").create(
class CodeChunks(LanceModel):
filename: str
text: str = func.SourceField()
# 1536 is the embedding dimension of the `voyage-code-3` model.
vector: Vector(1536) = func.VectorField()
# 1024 is the default dimension for `voyage-code-3`: https://docs.voyageai.com/docs/embeddings#model-choices
vector: Vector(1024) = func.VectorField()
table = db.create_table("code_chunks", schema=CodeChunks, mode="overwrite")
table.add([

View file

@ -145,15 +145,13 @@ 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).
- `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:
- `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 +159,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 +172,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:

View file

@ -106,7 +106,7 @@
"@aws-sdk/client-sagemaker-runtime": "^3.777.0",
"@aws-sdk/credential-providers": "^3.778.0",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "^1.0.77",
"@continuedev/config-yaml": "file:../packages/config-yaml",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.8",
"@continuedev/openai-adapters": "^1.0.18",

52
gui/package-lock.json generated
View file

@ -7,7 +7,7 @@
"name": "gui",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/config-yaml": "^1.0.77",
"@continuedev/config-yaml": "file:../packages/config-yaml",
"@headlessui/react": "^2.2.0",
"@heroicons/react": "^2.0.18",
"@reduxjs/toolkit": "^2.3.0",
@ -109,7 +109,7 @@
"@aws-sdk/client-sagemaker-runtime": "^3.777.0",
"@aws-sdk/credential-providers": "^3.778.0",
"@continuedev/config-types": "^1.0.13",
"@continuedev/config-yaml": "^1.0.77",
"@continuedev/config-yaml": "file:../packages/config-yaml",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.8",
"@continuedev/openai-adapters": "^1.0.18",
@ -204,6 +204,27 @@
"node": ">=20.11.0"
}
},
"../packages/config-yaml": {
"name": "@continuedev/config-yaml",
"version": "1.0.79",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/config-types": "^1.0.14",
"yaml": "^2.6.1",
"zod": "^3.24.2"
},
"bin": {
"config-yaml": "dist/cli.js"
},
"devDependencies": {
"@types/jest": "^29.5.14",
"@types/node": "^20.0.0",
"cross-env": "^7.0.3",
"jest": "^29.7.0",
"ts-jest": "^29.2.3",
"ts-node": "^10.9.2"
}
},
"node_modules/@adobe/css-tools": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/@adobe/css-tools/-/css-tools-4.4.0.tgz",
@ -544,23 +565,9 @@
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
"dev": true
},
"node_modules/@continuedev/config-types": {
"version": "1.0.14",
"resolved": "https://registry.npmjs.org/@continuedev/config-types/-/config-types-1.0.14.tgz",
"integrity": "sha512-PVHyHPyRXd2QsaNgnCpiKYU3uHFTlyuQSkqE8OwrBmQqO6/TXUVIr/2EGtyIZGrml4Y+rGMSH40WU4/0t4SGpQ==",
"dependencies": {
"zod": "^3.23.8"
}
},
"node_modules/@continuedev/config-yaml": {
"version": "1.0.77",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.77.tgz",
"integrity": "sha512-Vke6jp4bENjJc9fO1tavOnbYXRmmSIEzNhYeQ6DzZVl92+8rWwdO6zhbrK0r4FGjHnH0cJgyK/q0zX9/l+6asw==",
"dependencies": {
"@continuedev/config-types": "^1.0.14",
"yaml": "^2.6.1",
"zod": "^3.24.2"
}
"resolved": "../packages/config-yaml",
"link": true
},
"node_modules/@emotion/is-prop-valid": {
"version": "1.3.1",
@ -13773,6 +13780,7 @@
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/yaml/-/yaml-2.6.1.tgz",
"integrity": "sha512-7r0XPzioN/Q9kXBro/XPnA6kznR73DHq+GXh5ON7ZozRO6aMjbmiBuKste2wslTFkC5d1dw0GooOCepZXJ2SAg==",
"dev": true,
"bin": {
"yaml": "bin.mjs"
},
@ -13792,14 +13800,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/zod": {
"version": "3.24.2",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz",
"integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
},
"node_modules/zwitch": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz",

View file

@ -15,7 +15,7 @@
"test:watch": "vitest"
},
"dependencies": {
"@continuedev/config-yaml": "^1.0.77",
"@continuedev/config-yaml": "file:../packages/config-yaml",
"@headlessui/react": "^2.2.0",
"@heroicons/react": "^2.0.18",
"@reduxjs/toolkit": "^2.3.0",

View file

@ -4,7 +4,10 @@ import { useContext } from "react";
import { useAuth } from "../../../context/Auth";
import { IdeMessengerContext } from "../../../context/IdeMessenger";
type SectionKey = Exclude<keyof ConfigYaml, "name" | "version" | "schema">;
type SectionKey = Exclude<
keyof ConfigYaml,
"name" | "version" | "schema" | "metadata"
>;
interface EditBlockButtonProps<T extends SectionKey> {
blockType: T;

View file

@ -42,7 +42,7 @@ function ContextItemsPeekItem({ contextItem }: ContextItemsPeekItemProps) {
const isRangeInFile = name.includes(" (") && name.endsWith(")");
if (isRangeInFile) {
const rif = ctxItemToRifWithContents(contextItem);
const rif = ctxItemToRifWithContents(contextItem, true);
ideMessenger.ide.showLines(
rif.filepath,
rif.range.start.line,

View file

@ -52,9 +52,11 @@ export default function ApplyActions(props: ApplyActionsProps) {
case "streaming":
return (
<div className="flex items-center rounded bg-zinc-700 pl-2 pr-1">
<span className="inline-flex items-center gap-2 text-xs text-gray-400">
<span className="inline-flex w-min items-center gap-2 text-center text-xs text-gray-400">
Applying changes
<Spinner />
<div>
<Spinner />
</div>
</span>
</div>
);

View file

@ -223,7 +223,7 @@ function ModelSelect() {
ref={buttonRef}
className="h-[18px] gap-1 border-none text-gray-400"
>
<span className="line-clamp-1 hover:brightness-110">
<span className="line-clamp-1 break-all hover:brightness-110">
{modelSelectTitle(selectedChatModel) || "Select model"}
</span>
<ChevronDownIcon

View file

@ -50,7 +50,7 @@ function useSetup() {
organizations,
selectedOrgId,
} = result;
debugger;
if (isInitial && hasDoneInitialConfigLoad.current) {
return;
}

View file

@ -85,7 +85,10 @@ export const streamResponseThunk = createAsyncThunk<
// Construct messages from updated history
const updatedHistory = getState().session.history;
const messages = constructMessages([...updatedHistory]);
const messages = constructMessages(
[...updatedHistory],
selectedChatModel?.baseChatSystemMessage,
);
posthog.capture("step run", {
step_name: "User Input",

View file

@ -59,7 +59,10 @@ export const streamResponseAfterToolCall = createAsyncThunk<
dispatch(setActive());
const updatedHistory = getState().session.history;
const messages = constructMessages([...updatedHistory]);
const messages = constructMessages(
[...updatedHistory],
selectedChatModel?.baseChatSystemMessage,
);
unwrapResult(await dispatch(streamNormalInput({ messages })));
}),
);

View file

@ -1,20 +1,31 @@
{
"name": "@continuedev/config-types",
"version": "1.0.13",
"version": "1.0.14",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@continuedev/config-types",
"version": "1.0.13",
"version": "1.0.14",
"license": "Apache-2.0",
"dependencies": {
"zod": "^3.23.8"
"zod": "^3.24.2"
},
"devDependencies": {
"@types/node": "^20.11.19",
"typescript": "^5.5.2"
}
},
"node_modules/@types/node": {
"version": "20.17.30",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.30.tgz",
"integrity": "sha512-7zf4YyHA+jvBNfVrk2Gtvs6x7E8V+YDW05bNfG2XkWDJfYRXrTiP/DsB2zSYTaHX0bGIujTBQdMVAhb+j7mwpg==",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~6.19.2"
}
},
"node_modules/typescript": {
"version": "5.5.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.2.tgz",
@ -28,10 +39,18 @@
"node": ">=14.17"
}
},
"node_modules/undici-types": {
"version": "6.19.8",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
"dev": true,
"license": "MIT"
},
"node_modules/zod": {
"version": "3.23.8",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz",
"integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==",
"version": "3.24.2",
"resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz",
"integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}

View file

@ -12,9 +12,10 @@
"author": "Nate Sesti and Ty Dunn",
"license": "Apache-2.0",
"devDependencies": {
"@types/node": "^20.11.19",
"typescript": "^5.5.2"
},
"dependencies": {
"zod": "^3.24.2"
}
}
}

View file

@ -1,12 +1,12 @@
{
"name": "@continuedev/config-yaml",
"version": "1.0.72",
"version": "1.0.78",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@continuedev/config-yaml",
"version": "1.0.72",
"version": "1.0.78",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/config-types": "^1.0.14",

View file

@ -298,7 +298,7 @@ export async function unrollBlocks(
const sections: (keyof Omit<
ConfigYaml,
"name" | "version" | "rules" | "schema"
"name" | "version" | "rules" | "schema" | "metadata"
>)[] = ["models", "context", "data", "mcpServers", "prompts", "docs"];
// For each section, replace "uses/with" blocks with the real thing

View file

@ -56,6 +56,11 @@ export const embedOptionsSchema = z.object({
});
export type EmbedOptions = z.infer<typeof embedOptionsSchema>;
export const chatOptionsSchema = z.object({
baseSystemMessage: z.string().optional(),
});
export type ChatOptions = z.infer<typeof chatOptionsSchema>;
/** Prompt templates use Handlebars syntax */
const promptTemplatesSchema = z.object({
apply: z.string().optional(),
@ -73,6 +78,7 @@ const baseModelFields = {
defaultCompletionOptions: completionOptionsSchema.optional(),
requestOptions: requestOptionsSchema.optional(),
embedOptions: embedOptionsSchema.optional(),
chatOptions: chatOptionsSchema.optional(),
promptTemplates: promptTemplatesSchema.optional(),
env: z
.record(z.string(), z.union([z.string(), z.boolean(), z.number()]))