Commit 277ffdcb by t0ng7u

🎨 refactor: Refactor RatioSetting: integrate Group Ratio Settings into tabs

* Moved `GroupRatioSettings` component inside the existing Tabs as a new **Group Ratios** tab.
* Removed the standalone `Card` that previously wrapped `GroupRatioSettings`.
* Re-formatted JSX props for `ModelRatioSettings` and `GroupRatioSettings` to improve readability.
* Consolidates all ratio-related settings into a single tabbed view for a cleaner and more consistent UI.
parent d09292bd
...@@ -84,7 +84,16 @@ const RatioSetting = () => { ...@@ -84,7 +84,16 @@ const RatioSetting = () => {
<Card style={{ marginTop: '10px' }}> <Card style={{ marginTop: '10px' }}>
<Tabs type='card'> <Tabs type='card'>
<Tabs.TabPane tab={t('模型倍率设置')} itemKey='model'> <Tabs.TabPane tab={t('模型倍率设置')} itemKey='model'>
<ModelRatioSettings options={inputs} refresh={onRefresh} /> <ModelRatioSettings
options={inputs}
refresh={onRefresh}
/>
</Tabs.TabPane>
<Tabs.TabPane tab={t('分组倍率设置')} itemKey='group'>
<GroupRatioSettings
options={inputs}
refresh={onRefresh}
/>
</Tabs.TabPane> </Tabs.TabPane>
<Tabs.TabPane tab={t('可视化倍率设置')} itemKey='visual'> <Tabs.TabPane tab={t('可视化倍率设置')} itemKey='visual'>
<ModelSettingsVisualEditor <ModelSettingsVisualEditor
...@@ -106,10 +115,6 @@ const RatioSetting = () => { ...@@ -106,10 +115,6 @@ const RatioSetting = () => {
</Tabs.TabPane> </Tabs.TabPane>
</Tabs> </Tabs>
</Card> </Card>
{/* 分组倍率设置 */}
<Card style={{ marginTop: '10px' }}>
<GroupRatioSettings options={inputs} refresh={onRefresh} />
</Card>
</Spin> </Spin>
); );
}; };
......
...@@ -1263,7 +1263,7 @@ ...@@ -1263,7 +1263,7 @@
" 吗?": "?", " 吗?": "?",
"修改子渠道优先级": "Modify sub-channel priority", "修改子渠道优先级": "Modify sub-channel priority",
"确定要修改所有子渠道优先级为 ": "Confirm to modify all sub-channel priorities to ", "确定要修改所有子渠道优先级为 ": "Confirm to modify all sub-channel priorities to ",
"分组设置": "Group settings", "分组倍率设置": "Group ratio settings",
"用户可选分组": "User selectable groups", "用户可选分组": "User selectable groups",
"保存分组倍率设置": "Save group ratio settings", "保存分组倍率设置": "Save group ratio settings",
"模型倍率设置": "Model ratio settings", "模型倍率设置": "Model ratio settings",
......
...@@ -118,107 +118,105 @@ export default function ModelRatioSettings(props) { ...@@ -118,107 +118,105 @@ export default function ModelRatioSettings(props) {
getFormApi={(formAPI) => (refForm.current = formAPI)} getFormApi={(formAPI) => (refForm.current = formAPI)}
style={{ marginBottom: 15 }} style={{ marginBottom: 15 }}
> >
<Form.Section> <Row gutter={16}>
<Row gutter={16}> <Col xs={24} sm={16}>
<Col xs={24} sm={16}> <Form.TextArea
<Form.TextArea label={t('模型固定价格')}
label={t('模型固定价格')} extraText={t('一次调用消耗多少刀,优先级大于模型倍率')}
extraText={t('一次调用消耗多少刀,优先级大于模型倍率')} placeholder={t(
placeholder={t( '为一个 JSON 文本,键为模型名称,值为一次调用消耗多少刀,比如 "gpt-4-gizmo-*": 0.1,一次消耗0.1刀',
'为一个 JSON 文本,键为模型名称,值为一次调用消耗多少刀,比如 "gpt-4-gizmo-*": 0.1,一次消耗0.1刀', )}
)} field={'ModelPrice'}
field={'ModelPrice'} autosize={{ minRows: 6, maxRows: 12 }}
autosize={{ minRows: 6, maxRows: 12 }} trigger='blur'
trigger='blur' stopValidateWithError
stopValidateWithError rules={[
rules={[ {
{ validator: (rule, value) => verifyJSON(value),
validator: (rule, value) => verifyJSON(value), message: '不是合法的 JSON 字符串',
message: '不是合法的 JSON 字符串', },
}, ]}
]} onChange={(value) =>
onChange={(value) => setInputs({ ...inputs, ModelPrice: value })
setInputs({ ...inputs, ModelPrice: value }) }
} />
/> </Col>
</Col> </Row>
</Row> <Row gutter={16}>
<Row gutter={16}> <Col xs={24} sm={16}>
<Col xs={24} sm={16}> <Form.TextArea
<Form.TextArea label={t('模型倍率')}
label={t('模型倍率')} placeholder={t('为一个 JSON 文本,键为模型名称,值为倍率')}
placeholder={t('为一个 JSON 文本,键为模型名称,值为倍率')} field={'ModelRatio'}
field={'ModelRatio'} autosize={{ minRows: 6, maxRows: 12 }}
autosize={{ minRows: 6, maxRows: 12 }} trigger='blur'
trigger='blur' stopValidateWithError
stopValidateWithError rules={[
rules={[ {
{ validator: (rule, value) => verifyJSON(value),
validator: (rule, value) => verifyJSON(value), message: '不是合法的 JSON 字符串',
message: '不是合法的 JSON 字符串', },
}, ]}
]} onChange={(value) =>
onChange={(value) => setInputs({ ...inputs, ModelRatio: value })
setInputs({ ...inputs, ModelRatio: value }) }
} />
/> </Col>
</Col> </Row>
</Row> <Row gutter={16}>
<Row gutter={16}> <Col xs={24} sm={16}>
<Col xs={24} sm={16}> <Form.TextArea
<Form.TextArea label={t('提示缓存倍率')}
label={t('提示缓存倍率')} placeholder={t('为一个 JSON 文本,键为模型名称,值为倍率')}
placeholder={t('为一个 JSON 文本,键为模型名称,值为倍率')} field={'CacheRatio'}
field={'CacheRatio'} autosize={{ minRows: 6, maxRows: 12 }}
autosize={{ minRows: 6, maxRows: 12 }} trigger='blur'
trigger='blur' stopValidateWithError
stopValidateWithError rules={[
rules={[ {
{ validator: (rule, value) => verifyJSON(value),
validator: (rule, value) => verifyJSON(value), message: '不是合法的 JSON 字符串',
message: '不是合法的 JSON 字符串', },
}, ]}
]} onChange={(value) =>
onChange={(value) => setInputs({ ...inputs, CacheRatio: value })
setInputs({ ...inputs, CacheRatio: value }) }
} />
/> </Col>
</Col> </Row>
</Row> <Row gutter={16}>
<Row gutter={16}> <Col xs={24} sm={16}>
<Col xs={24} sm={16}> <Form.TextArea
<Form.TextArea label={t('模型补全倍率(仅对自定义模型有效)')}
label={t('模型补全倍率(仅对自定义模型有效)')} extraText={t('仅对自定义模型有效')}
extraText={t('仅对自定义模型有效')} placeholder={t('为一个 JSON 文本,键为模型名称,值为倍率')}
placeholder={t('为一个 JSON 文本,键为模型名称,值为倍率')} field={'CompletionRatio'}
field={'CompletionRatio'} autosize={{ minRows: 6, maxRows: 12 }}
autosize={{ minRows: 6, maxRows: 12 }} trigger='blur'
trigger='blur' stopValidateWithError
stopValidateWithError rules={[
rules={[ {
{ validator: (rule, value) => verifyJSON(value),
validator: (rule, value) => verifyJSON(value), message: '不是合法的 JSON 字符串',
message: '不是合法的 JSON 字符串', },
}, ]}
]} onChange={(value) =>
onChange={(value) => setInputs({ ...inputs, CompletionRatio: value })
setInputs({ ...inputs, CompletionRatio: value }) }
} />
/> </Col>
</Col> </Row>
</Row> <Row gutter={16}>
<Row gutter={16}> <Col span={16}>
<Col span={16}> <Form.Switch
<Form.Switch label={t('暴露倍率接口')}
label={t('暴露倍率接口')} field={'ExposeRatioEnabled'}
field={'ExposeRatioEnabled'} onChange={(value) =>
onChange={(value) => setInputs({ ...inputs, ExposeRatioEnabled: value })
setInputs({ ...inputs, ExposeRatioEnabled: value }) }
} />
/> </Col>
</Col> </Row>
</Row>
</Form.Section>
</Form> </Form>
<Space> <Space>
<Button onClick={onSubmit}>{t('保存模型倍率设置')}</Button> <Button onClick={onSubmit}>{t('保存模型倍率设置')}</Button>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment