mirror of
https://github.com/songquanpeng/one-api.git
synced 2026-04-21 09:24:28 +08:00
feat: support new ratio for all ui
This commit is contained in:
@@ -18,6 +18,12 @@ import { DateTimePicker } from "@mui/x-date-pickers/DateTimePicker";
|
||||
import dayjs from "dayjs";
|
||||
require("dayjs/locale/zh-cn");
|
||||
|
||||
const RATIO_MAPPING_EXAMPLE = {
|
||||
'gpt-4o-mini': {'input': 0.075, 'output': 0.3},
|
||||
'llama3-8b-8192(33)': {'input': 0.15, 'output': 0.3},
|
||||
'llama3-70b-8192(33)': {'input': 1.325, 'output': 1.749},
|
||||
};
|
||||
|
||||
const OperationSetting = () => {
|
||||
let now = new Date();
|
||||
let [inputs, setInputs] = useState({
|
||||
@@ -26,8 +32,7 @@ const OperationSetting = () => {
|
||||
QuotaForInvitee: 0,
|
||||
QuotaRemindThreshold: 0,
|
||||
PreConsumedQuota: 0,
|
||||
ModelRatio: "",
|
||||
CompletionRatio: "",
|
||||
Ratio: "",
|
||||
GroupRatio: "",
|
||||
TopUpLink: "",
|
||||
ChatLink: "",
|
||||
@@ -53,7 +58,7 @@ const OperationSetting = () => {
|
||||
if (success) {
|
||||
let newInputs = {};
|
||||
data.forEach((item) => {
|
||||
if (item.key === "ModelRatio" || item.key === "GroupRatio" || item.key === "CompletionRatio") {
|
||||
if (item.key === "GroupRatio" || item.key === "Ratio") {
|
||||
item.value = JSON.stringify(JSON.parse(item.value), null, 2);
|
||||
}
|
||||
if (item.value === '{}') {
|
||||
@@ -123,12 +128,12 @@ const OperationSetting = () => {
|
||||
}
|
||||
break;
|
||||
case "ratio":
|
||||
if (originInputs["ModelRatio"] !== inputs.ModelRatio) {
|
||||
if (!verifyJSON(inputs.ModelRatio)) {
|
||||
showError("模型倍率不是合法的 JSON 字符串");
|
||||
if (originInputs["Ratio"] !== inputs.Ratio) {
|
||||
if (!verifyJSON(inputs.Ratio)) {
|
||||
showError("自定义倍率不是合法的 JSON 字符串");
|
||||
return;
|
||||
}
|
||||
await updateOption("ModelRatio", inputs.ModelRatio);
|
||||
await updateOption("Ratio", inputs.Ratio);
|
||||
}
|
||||
if (originInputs["GroupRatio"] !== inputs.GroupRatio) {
|
||||
if (!verifyJSON(inputs.GroupRatio)) {
|
||||
@@ -137,13 +142,6 @@ const OperationSetting = () => {
|
||||
}
|
||||
await updateOption("GroupRatio", inputs.GroupRatio);
|
||||
}
|
||||
if (originInputs['CompletionRatio'] !== inputs.CompletionRatio) {
|
||||
if (!verifyJSON(inputs.CompletionRatio)) {
|
||||
showError('补全倍率不是合法的 JSON 字符串');
|
||||
return;
|
||||
}
|
||||
await updateOption('CompletionRatio', inputs.CompletionRatio);
|
||||
}
|
||||
break;
|
||||
case "quota":
|
||||
if (originInputs["QuotaForNewUser"] !== inputs.QuotaForNewUser) {
|
||||
@@ -501,28 +499,14 @@ const OperationSetting = () => {
|
||||
<TextField
|
||||
multiline
|
||||
maxRows={15}
|
||||
id="channel-ModelRatio-label"
|
||||
label="模型倍率"
|
||||
value={inputs.ModelRatio}
|
||||
name="ModelRatio"
|
||||
id="channel-Ratio-label"
|
||||
label="自定义倍率"
|
||||
value={inputs.Ratio}
|
||||
name="Ratio"
|
||||
onChange={handleInputChange}
|
||||
aria-describedby="helper-text-channel-ModelRatio-label"
|
||||
aria-describedby="helper-text-channel-Ratio-label"
|
||||
minRows={5}
|
||||
placeholder="为一个 JSON 文本,键为模型名称,值为倍率"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControl fullWidth>
|
||||
<TextField
|
||||
multiline
|
||||
maxRows={15}
|
||||
id="channel-CompletionRatio-label"
|
||||
label="补全倍率"
|
||||
value={inputs.CompletionRatio}
|
||||
name="CompletionRatio"
|
||||
onChange={handleInputChange}
|
||||
aria-describedby="helper-text-channel-CompletionRatio-label"
|
||||
minRows={5}
|
||||
placeholder="为一个 JSON 文本,键为模型名称,值为倍率,此处的倍率设置是模型补全倍率相较于提示倍率的比例,使用该设置可强制覆盖 One API 的内部比例"
|
||||
placeholder={`为一个 JSON 文本,键为模型名称,值为倍率结构,例如:\n${JSON.stringify(RATIO_MAPPING_EXAMPLE, null, 2)}`}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormControl fullWidth>
|
||||
|
||||
Reference in New Issue
Block a user