feat: Add frequency_penalty request parameter

This commit is contained in:
AngelLiang 2023-06-04 16:05:35 +08:00
parent 5e274130a6
commit 72cbb156ae
18 changed files with 104 additions and 0 deletions

View File

@ -46,6 +46,7 @@ export class ChatGPTApi implements LLMApi {
model: modelConfig.model, model: modelConfig.model,
temperature: modelConfig.temperature, temperature: modelConfig.temperature,
presence_penalty: modelConfig.presence_penalty, presence_penalty: modelConfig.presence_penalty,
frequency_penalty: modelConfig.frequency_penalty,
}; };
console.log("[Request] openai payload: ", requestPayload); console.log("[Request] openai payload: ", requestPayload);

View File

@ -88,6 +88,27 @@ export function ModelConfigList(props: {
></InputRange> ></InputRange>
</ListItem> </ListItem>
<ListItem
title={Locale.Settings.FrequencyPenalty.Title}
subTitle={Locale.Settings.FrequencyPenalty.SubTitle}
>
<InputRange
value={props.modelConfig.frequency_penalty?.toFixed(1)}
min="-2"
max="2"
step="0.1"
onChange={(e) => {
props.updateConfig(
(config) =>
(config.frequency_penalty =
ModalConfigValidator.frequency_penalty(
e.currentTarget.valueAsNumber,
)),
);
}}
></InputRange>
</ListItem>
<ListItem <ListItem
title={Locale.Settings.HistoryCount.Title} title={Locale.Settings.HistoryCount.Title}
subTitle={Locale.Settings.HistoryCount.SubTitle} subTitle={Locale.Settings.HistoryCount.SubTitle}

View File

@ -173,6 +173,10 @@ const cn = {
Title: "话题新鲜度 (presence_penalty)", Title: "话题新鲜度 (presence_penalty)",
SubTitle: "值越大,越有可能扩展到新话题", SubTitle: "值越大,越有可能扩展到新话题",
}, },
FrequencyPenalty: {
Title: "频率惩罚度 (frequency_penalty)",
SubTitle: "值越大,越有可能降低重复字词",
},
}, },
Store: { Store: {
DefaultTopic: "新的聊天", DefaultTopic: "新的聊天",

View File

@ -155,6 +155,11 @@ const cs: LocaleType = {
Title: "Přítomnostní korekce", Title: "Přítomnostní korekce",
SubTitle: "Větší hodnota zvyšuje pravděpodobnost nových témat.", SubTitle: "Větší hodnota zvyšuje pravděpodobnost nových témat.",
}, },
FrequencyPenalty: {
Title: "Frekvenční penalizace",
SubTitle:
"Větší hodnota snižující pravděpodobnost opakování stejného řádku",
},
}, },
Store: { Store: {
DefaultTopic: "Nová konverzace", DefaultTopic: "Nová konverzace",

View File

@ -158,6 +158,11 @@ const de: LocaleType = {
SubTitle: SubTitle:
"Ein größerer Wert erhöht die Wahrscheinlichkeit, dass über neue Themen gesprochen wird", "Ein größerer Wert erhöht die Wahrscheinlichkeit, dass über neue Themen gesprochen wird",
}, },
FrequencyPenalty: {
Title: "Frequency Penalty", // HäufigkeitStrafe
SubTitle:
"Ein größerer Wert, der die Wahrscheinlichkeit verringert, dass dieselbe Zeile wiederholt wird",
},
}, },
Store: { Store: {
DefaultTopic: "Neues Gespräch", DefaultTopic: "Neues Gespräch",

View File

@ -175,6 +175,11 @@ const en: RequiredLocaleType = {
SubTitle: SubTitle:
"A larger value increases the likelihood to talk about new topics", "A larger value increases the likelihood to talk about new topics",
}, },
FrequencyPenalty: {
Title: "Frequency Penalty",
SubTitle:
"A larger value decreasing the likelihood to repeat the same line",
},
}, },
Store: { Store: {
DefaultTopic: "New Conversation", DefaultTopic: "New Conversation",

View File

@ -156,6 +156,11 @@ const es: LocaleType = {
SubTitle: SubTitle:
"Un valor mayor aumenta la probabilidad de hablar sobre nuevos temas", "Un valor mayor aumenta la probabilidad de hablar sobre nuevos temas",
}, },
FrequencyPenalty: {
Title: "Penalización de frecuencia",
SubTitle:
"Un valor mayor que disminuye la probabilidad de repetir la misma línea",
},
}, },
Store: { Store: {
DefaultTopic: "Nueva conversación", DefaultTopic: "Nueva conversación",

View File

@ -159,6 +159,11 @@ const fr: LocaleType = {
SubTitle: SubTitle:
"Une valeur plus élevée augmentera la probabilité d'introduire de nouveaux sujets", "Une valeur plus élevée augmentera la probabilité d'introduire de nouveaux sujets",
}, },
FrequencyPenalty: {
Title: "Pénalité de fréquence",
SubTitle:
"Une valeur plus élevée diminuant la probabilité de répéter la même ligne",
},
}, },
Store: { Store: {
DefaultTopic: "Nouvelle conversation", DefaultTopic: "Nouvelle conversation",

View File

@ -157,6 +157,11 @@ const it: LocaleType = {
SubTitle: SubTitle:
"Un valore maggiore aumenta la probabilità di parlare di nuovi argomenti", "Un valore maggiore aumenta la probabilità di parlare di nuovi argomenti",
}, },
FrequencyPenalty: {
Title: "Penalità di frequenza",
SubTitle:
"Un valore maggiore che diminuisce la probabilità di ripetere la stessa riga",
},
}, },
Store: { Store: {
DefaultTopic: "Nuova conversazione", DefaultTopic: "Nuova conversazione",

View File

@ -158,6 +158,10 @@ const jp: LocaleType = {
Title: "トピックの新鮮度 (presence_penalty)", Title: "トピックの新鮮度 (presence_penalty)",
SubTitle: "値が大きいほど、新しいトピックへの展開が可能になります。", SubTitle: "値が大きいほど、新しいトピックへの展開が可能になります。",
}, },
FrequencyPenalty: {
Title: "話題の頻度 (frequency_penalty)",
SubTitle: "値が大きいほど、重複語を低減する可能性が高くなります",
},
}, },
Store: { Store: {
DefaultTopic: "新しいチャット", DefaultTopic: "新しいチャット",

View File

@ -154,6 +154,10 @@ const ko: LocaleType = {
Title: "존재 페널티 (presence_penalty)", Title: "존재 페널티 (presence_penalty)",
SubTitle: "값이 클수록 새로운 주제에 대해 대화할 가능성이 높아집니다.", SubTitle: "값이 클수록 새로운 주제에 대해 대화할 가능성이 높아집니다.",
}, },
FrequencyPenalty: {
Title: "빈도 페널티(frequency penalty)",
SubTitle: "값이 클수록 같은 줄이 반복될 가능성이 줄어듭니다.",
},
}, },
Store: { Store: {
DefaultTopic: "새 대화", DefaultTopic: "새 대화",

View File

@ -157,6 +157,11 @@ const ru: LocaleType = {
SubTitle: SubTitle:
"Чем выше значение, тем больше вероятность общения на новые темы", "Чем выше значение, тем больше вероятность общения на новые темы",
}, },
FrequencyPenalty: {
Title: "Штраф за частоту",
SubTitle:
"Большее значение снижает вероятность повторения одной и той же строки",
},
}, },
Store: { Store: {
DefaultTopic: "Новый разговор", DefaultTopic: "Новый разговор",

View File

@ -158,6 +158,11 @@ const tr: LocaleType = {
SubTitle: SubTitle:
"Daha büyük bir değer, yeni konular hakkında konuşma olasılığını artırır", "Daha büyük bir değer, yeni konular hakkında konuşma olasılığını artırır",
}, },
FrequencyPenalty: {
Title: "Frekans Cezası",
SubTitle:
"Aynı satırı tekrar etme olasılığını azaltan daha büyük bir değer",
},
}, },
Store: { Store: {
DefaultTopic: "Yeni Konuşma", DefaultTopic: "Yeni Konuşma",

View File

@ -152,6 +152,10 @@ const tw: LocaleType = {
Title: "話題新穎度 (presence_penalty)", Title: "話題新穎度 (presence_penalty)",
SubTitle: "值越大,越有可能擴展到新話題", SubTitle: "值越大,越有可能擴展到新話題",
}, },
FrequencyPenalty: {
Title: "頻率懲罰度 (frequency_penalty)",
SubTitle: "值越大,越有可能降低重複字詞",
},
}, },
Store: { Store: {
DefaultTopic: "新的對話", DefaultTopic: "新的對話",

View File

@ -154,6 +154,10 @@ const vi: LocaleType = {
Title: "Chủ đề mới (presence_penalty)", Title: "Chủ đề mới (presence_penalty)",
SubTitle: "Giá trị càng lớn tăng khả năng mở rộng sang các chủ đề mới", SubTitle: "Giá trị càng lớn tăng khả năng mở rộng sang các chủ đề mới",
}, },
FrequencyPenalty: {
Title: "Hình phạt tần suất",
SubTitle: "Giá trị lớn hơn làm giảm khả năng lặp lại cùng một dòng",
},
}, },
Store: { Store: {
DefaultTopic: "Cuộc trò chuyện mới", DefaultTopic: "Cuộc trò chuyện mới",

View File

@ -29,6 +29,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 1, temperature: 1,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true, sendMemory: true,
historyMessageCount: 32, historyMessageCount: 32,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -52,6 +53,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 1, temperature: 1,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true, sendMemory: true,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -75,6 +77,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 1, temperature: 1,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true, sendMemory: true,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -98,6 +101,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 1, temperature: 1,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true, sendMemory: true,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -121,6 +125,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 1, temperature: 1,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true, sendMemory: true,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -144,6 +149,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 1, temperature: 1,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: false, sendMemory: false,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -167,6 +173,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 1, temperature: 1,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: false, sendMemory: false,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -190,6 +197,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 1, temperature: 1,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: false, sendMemory: false,
historyMessageCount: 0, historyMessageCount: 0,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -218,6 +226,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 0.5, temperature: 0.5,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true, sendMemory: true,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -241,6 +250,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 1, temperature: 1,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true, sendMemory: true,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -270,6 +280,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 1, temperature: 1,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: false, sendMemory: false,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -299,6 +310,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 1, temperature: 1,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: false, sendMemory: false,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -349,6 +361,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 1, temperature: 1,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: false, sendMemory: false,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -377,6 +390,7 @@ export const CN_MASKS: BuiltinMask[] = [
temperature: 0.5, temperature: 0.5,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true, sendMemory: true,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,

View File

@ -17,6 +17,7 @@ export const EN_MASKS: BuiltinMask[] = [
temperature: 0.3, temperature: 0.3,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true, sendMemory: true,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -57,6 +58,7 @@ export const EN_MASKS: BuiltinMask[] = [
temperature: 0.5, temperature: 0.5,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true, sendMemory: true,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -80,6 +82,7 @@ export const EN_MASKS: BuiltinMask[] = [
temperature: 0.5, temperature: 0.5,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true, sendMemory: true,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -108,6 +111,7 @@ export const EN_MASKS: BuiltinMask[] = [
temperature: 0.5, temperature: 0.5,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true, sendMemory: true,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 2000, compressMessageLengthThreshold: 2000,

View File

@ -34,6 +34,7 @@ export const DEFAULT_CONFIG = {
temperature: 0.5, temperature: 0.5,
max_tokens: 2000, max_tokens: 2000,
presence_penalty: 0, presence_penalty: 0,
frequency_penalty: 0,
sendMemory: true, sendMemory: true,
historyMessageCount: 4, historyMessageCount: 4,
compressMessageLengthThreshold: 1000, compressMessageLengthThreshold: 1000,
@ -137,6 +138,9 @@ export const ModalConfigValidator = {
presence_penalty(x: number) { presence_penalty(x: number) {
return limitNumber(x, -2, 2, 0); return limitNumber(x, -2, 2, 0);
}, },
frequency_penalty(x: number) {
return limitNumber(x, -2, 2, 0);
},
temperature(x: number) { temperature(x: number) {
return limitNumber(x, 0, 1, 1); return limitNumber(x, 0, 1, 1);
}, },