Add ChatML and Rework display

This commit is contained in:
kwaroran
2024-12-01 17:05:50 +09:00
parent 5ebb934d3b
commit 8a6cfedcda
4 changed files with 234 additions and 86 deletions

View File

@@ -4,7 +4,7 @@ import { getDatabase, presetTemplate, setDatabase, type Database } from "../stor
import { alertError, alertNormal } from "../alert";
import type { OobaChatCompletionRequestParams } from "../model/ooba";
export type PromptItem = PromptItemPlain|PromptItemTyped|PromptItemChat|PromptItemAuthorNote;
export type PromptItem = PromptItemPlain|PromptItemTyped|PromptItemChat|PromptItemAuthorNote|PromptItemChatML
export type PromptType = PromptItem['type'];
export type PromptSettings = {
assistantPrefill: string
@@ -21,17 +21,26 @@ export interface PromptItemPlain {
type2: 'normal'|'globalNote'|'main'
text: string;
role: 'user'|'bot'|'system';
name?: string
}
export interface PromptItemChatML {
type: 'chatML'
text: string
name?: string
}
export interface PromptItemTyped {
type: 'persona'|'description'|'lorebook'|'postEverything'|'memory'
innerFormat?: string
innerFormat?: string,
name?: string
}
export interface PromptItemAuthorNote {
type : 'authornote'
innerFormat?: string
defaultText?: string
name?: string
}
@@ -40,6 +49,7 @@ export interface PromptItemChat {
rangeStart: number;
rangeEnd: number|'end';
chatAsOriginalOnSystem?: boolean;
name?: string
}
export async function tokenizePreset(prompts:PromptItem[], consti:boolean = false){