✨ allow setting promptTemplates in config.json
This commit is contained in:
parent
03350455e3
commit
cbd2583901
6 changed files with 52 additions and 7 deletions
|
|
@ -414,7 +414,7 @@ const EditSlashCommand: SlashCommand = {
|
|||
let lineBelowHighlightedRange = fileSuffix.trim().split("\n")[0];
|
||||
|
||||
// Use custom templates defined by the model
|
||||
const template = llm.promptTemplates?.["edit"];
|
||||
const template = llm.promptTemplates?.edit;
|
||||
let generator: AsyncGenerator<string>;
|
||||
if (template) {
|
||||
let rendered = renderPromptTemplate(
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ declare global {
|
|||
temperature?: number;
|
||||
topP?: number;
|
||||
topK?: number;
|
||||
minP?: number;
|
||||
presencePenalty?: number;
|
||||
frequencyPenalty?: number;
|
||||
stop?: string[];
|
||||
|
|
@ -166,6 +167,7 @@ declare global {
|
|||
temperature?: number;
|
||||
topP?: number;
|
||||
topK?: number;
|
||||
minP?: number;
|
||||
presencePenalty?: number;
|
||||
frequencyPenalty?: number;
|
||||
stop?: string[];
|
||||
|
|
@ -229,6 +231,11 @@ declare global {
|
|||
|
||||
// IDE
|
||||
|
||||
export interface DiffLine {
|
||||
type: "new" | "old" | "same";
|
||||
line: string;
|
||||
}
|
||||
|
||||
export interface IDE {
|
||||
getSerializedConfig(): Promise<SerializedContinueConfig>;
|
||||
getConfigJsUrl(): Promise<string | undefined>;
|
||||
|
|
@ -248,6 +255,12 @@ declare global {
|
|||
newContents: string,
|
||||
stepIndex: number
|
||||
): Promise<void>;
|
||||
verticalDiffUpdate(
|
||||
filepath: string,
|
||||
startLine: number,
|
||||
endLine: number,
|
||||
diffLine: DiffLine
|
||||
): Promise<void>;
|
||||
getOpenFiles(): Promise<string[]>;
|
||||
}
|
||||
|
||||
|
|
@ -411,6 +424,7 @@ declare global {
|
|||
temperature?: number;
|
||||
topP?: number;
|
||||
topK?: number;
|
||||
minP?: number;
|
||||
presencePenalty?: number;
|
||||
frequencyPenalty?: number;
|
||||
stop?: string[];
|
||||
|
|
@ -428,6 +442,7 @@ declare global {
|
|||
completionOptions?: BaseCompletionOptions;
|
||||
systemMessage?: string;
|
||||
requestOptions?: RequestOptions;
|
||||
promptTemplates?: { [key: string]: string };
|
||||
}
|
||||
|
||||
export interface ModelRoles {
|
||||
|
|
|
|||
1
core/index.d.ts
vendored
1
core/index.d.ts
vendored
|
|
@ -440,6 +440,7 @@ export interface ModelDescription {
|
|||
completionOptions?: BaseCompletionOptions;
|
||||
systemMessage?: string;
|
||||
requestOptions?: RequestOptions;
|
||||
promptTemplates?: { [key: string]: string };
|
||||
}
|
||||
|
||||
export interface ModelRoles {
|
||||
|
|
|
|||
|
|
@ -197,8 +197,8 @@ export abstract class BaseLLM implements ILLM {
|
|||
};
|
||||
this.requestOptions = options.requestOptions;
|
||||
this.promptTemplates = {
|
||||
...options.promptTemplates,
|
||||
...autodetectPromptTemplates(options.model, templateType),
|
||||
...options.promptTemplates,
|
||||
};
|
||||
this.templateMessages =
|
||||
options.templateMessages ||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,32 @@
|
|||
function mergeSortAlgorithm() {
|
||||
// TODO: implement
|
||||
function mergeSortAlgorithm(arr) {
|
||||
// If the length of the array is less than or equal to one, return the original array
|
||||
if (arr.length <= 1) {
|
||||
return arr;
|
||||
}
|
||||
|
||||
// Find the middle index of the array
|
||||
const mid = Math.floor(arr.length / 2);
|
||||
|
||||
// Split the array into two halves: left and right
|
||||
const left = arr.slice(0, mid);
|
||||
const right = arr.slice(mid);
|
||||
|
||||
// Recursively sort the left and right arrays
|
||||
return merge(mergeSortAlgorithm(left), mergeSortAlgorithm(right));
|
||||
}
|
||||
|
||||
function merge(left, right) {
|
||||
let result = [];
|
||||
let leftIndex = 0;
|
||||
let rightIndex = 0;
|
||||
while (leftIndex < left.length && rightIndex < right.length) {
|
||||
if (left[leftIndex] < right[rightIndex]) {
|
||||
result.push(left[leftIndex]);
|
||||
leftIndex++;
|
||||
} else {
|
||||
result.push(right[rightIndex]);
|
||||
rightIndex++;
|
||||
}
|
||||
}
|
||||
return result.concat(left.slice(leftIndex)).concat(right.slice(rightIndex));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/* Terminal emulator - commented because node-pty is causing problems. */
|
||||
|
||||
import * as vscode from "vscode";
|
||||
import * as os from 'os';
|
||||
import * as os from "os";
|
||||
import stripAnsi from "strip-ansi";
|
||||
import * as vscode from "vscode";
|
||||
import { longestCommonSubsequence } from "../util/lcs";
|
||||
|
||||
function loadNativeModule<T>(id: string): T | null {
|
||||
|
|
@ -25,7 +25,7 @@ const pty = loadNativeModule<any>("node-pty");
|
|||
|
||||
function getDefaultShell(): string {
|
||||
if (process.platform !== "win32") {
|
||||
return os.userInfo().shell;
|
||||
return os.userInfo().shell || "cmd";
|
||||
}
|
||||
switch (process.platform) {
|
||||
case "win32":
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue