feats: the flexable params override and compatible format

This commit is contained in:
Nekohy
2025-08-16 11:27:47 +08:00
parent f6a48434c1
commit dd497d5bd8
10 changed files with 377 additions and 56 deletions

View File

@@ -1653,25 +1653,53 @@ const EditChannelModal = (props) => {
/>
<Form.TextArea
field='param_override'
label={t('参数覆盖')}
placeholder={
t('此项可选,用于覆盖请求参数。不支持覆盖 stream 参数。为一个 JSON 字符串,例如:') +
'\n{\n "temperature": 0\n}'
}
autosize
onChange={(value) => handleInputChange('param_override', value)}
extraText={
<Text
className="!text-semi-color-primary cursor-pointer"
onClick={() => handleInputChange('param_override', JSON.stringify({ temperature: 0 }, null, 2))}
>
{t('填入模板')}
</Text>
}
showClear
field='param_override'
label={t('参数覆盖')}
placeholder={
t('此项可选,用于覆盖请求参数。不支持覆盖 stream 参数') +
'\n' + t('旧格式(直接覆盖):') +
'\n{\n "temperature": 0,\n "max_tokens": 1000\n}' +
'\n\n' + t('新格式支持条件判断与json自定义') +
'\n{\n "operations": [\n {\n "path": "temperature",\n "mode": "set",\n "value": 0.7,\n "conditions": [\n {\n "path": "model",\n "mode": "prefix",\n "value": "gpt"\n }\n ]\n }\n ]\n}'
}
autosize
onChange={(value) => handleInputChange('param_override', value)}
extraText={
<div className="flex gap-2 flex-wrap">
<Text
className="!text-semi-color-primary cursor-pointer"
onClick={() => handleInputChange('param_override', JSON.stringify({ temperature: 0 }, null, 2))}
>
{t('旧格式模板')}
</Text>
<Text
className="!text-semi-color-primary cursor-pointer"
onClick={() => handleInputChange('param_override', JSON.stringify({
operations: [
{
path: "temperature",
mode: "set",
value: 0.7,
conditions: [
{
path: "model",
mode: "prefix",
value: "gpt"
}
],
logic: "AND"
}
]
}, null, 2))}
>
{t('新格式模板')}
</Text>
</div>
}
showClear
/>
<JSONEditor
key={`status_code_mapping-${isEdit ? channelId : 'new'}`}
field='status_code_mapping'