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,
temperature: modelConfig.temperature,
presence_penalty: modelConfig.presence_penalty,
frequency_penalty: modelConfig.frequency_penalty,
};
console.log("[Request] openai payload: ", requestPayload);

View File

@ -88,6 +88,27 @@ export function ModelConfigList(props: {
></InputRange>
</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
title={Locale.Settings.HistoryCount.Title}
subTitle={Locale.Settings.HistoryCount.SubTitle}

View File

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

View File

@ -155,6 +155,11 @@ const cs: LocaleType = {
Title: "Přítomnostní korekce",
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: {
DefaultTopic: "Nová konverzace",

View File

@ -158,6 +158,11 @@ const de: LocaleType = {
SubTitle:
"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: {
DefaultTopic: "Neues Gespräch",

View File

@ -175,6 +175,11 @@ const en: RequiredLocaleType = {
SubTitle:
"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: {
DefaultTopic: "New Conversation",

View File

@ -156,6 +156,11 @@ const es: LocaleType = {
SubTitle:
"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: {
DefaultTopic: "Nueva conversación",

View File

@ -159,6 +159,11 @@ const fr: LocaleType = {
SubTitle:
"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: {
DefaultTopic: "Nouvelle conversation",

View File

@ -157,6 +157,11 @@ const it: LocaleType = {
SubTitle:
"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: {
DefaultTopic: "Nuova conversazione",

View File

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

View File

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

View File

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

View File

@ -158,6 +158,11 @@ const tr: LocaleType = {
SubTitle:
"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: {
DefaultTopic: "Yeni Konuşma",

View File

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

View File

@ -154,6 +154,10 @@ const vi: LocaleType = {
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",
},
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: {
DefaultTopic: "Cuộc trò chuyện mới",

View File

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

View File

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

View File

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