feat: Add max output tokens configuration to Config page

This commit adds the configuration option for setting the maximum number of tokens output in the Config page. It includes the necessary changes to the Config.tsx file and the ConfigStore.ts file to handle the new "max_tokens" property in the models. This enhancement allows users to customize the maximum number of tokens generated by the chat models.
This commit is contained in:
bobo 2024-05-24 18:48:04 +08:00
parent 270b55e5de
commit 00f6abc1d6
2 changed files with 17 additions and 0 deletions

View File

@ -356,6 +356,15 @@ const Config = observer(() => {
value={form.values?.models[current]?.max_input_tokens}
onChange={(value) => changeModelDetail("max_input_tokens", value)}
/>
<NumberInput
label={t("Max output tokens")}
description={t(
"the maximum number of tokens output"
)}
styles={commonInputStyle}
value={form.values?.models[current]?.max_tokens}
onChange={(value) => changeModelDetail("max_tokens", value)}
/>
{showProvider && (
<Select
label={t("Provider")}

View File

@ -32,6 +32,10 @@ export const Model = types.model({
stream: types.boolean,
max_input_tokens: types.number,
category: types.string,
context_size: types.number,
temperature: types.number,
max_tokens: types.number,
json_mode: types.boolean,
});
export const ConfigStore = types
@ -55,6 +59,10 @@ export const ConfigStore = types
provider: provider,
stream: true,
category: item.category ?? "chat",
context_size: item.context_size ?? 8000,
temperature: item.temperature ?? 0.3,
max_tokens: item.max_tokens ?? 2000,
json_mode: item.json_mode ?? false,
};
});
self.modelNames = value