feat: chat presets (experimental)

This commit is contained in:
josc146
2023-06-25 00:07:14 +08:00
parent 08cf09416a
commit db67f30082
15 changed files with 987 additions and 212 deletions

View File

@@ -1,27 +0,0 @@
export type Record = {
question: string;
answer: string;
}
export type ConversationPair = {
role: string;
content: string;
}
export function getConversationPairs(records: Record[], isCompletion: boolean): string | ConversationPair[] {
let pairs;
if (isCompletion) {
pairs = '';
for (const record of records) {
pairs += 'Human: ' + record.question + '\nAI: ' + record.answer + '\n';
}
} else {
pairs = [];
for (const record of records) {
pairs.push({ role: 'user', content: record.question });
pairs.push({ role: 'assistant', content: record.answer });
}
}
return pairs;
}

View File

@@ -206,6 +206,10 @@ export const saveCache = async () => {
return SaveJson('cache.json', data);
};
export const savePresets = async () => {
return SaveJson('presets.json', commonStore.presets);
};
export function getUserLanguage(): Language {
// const l = navigator.language.toLowerCase();
// if (['zh-hk', 'zh-mo', 'zh-tw', 'zh-cht', 'zh-hant'].includes(l)) return 'zhHant'