Merge pull request #4142 from seefs001/fix/skip_failure_option
Some checks failed
Publish Docker image (Multi Registries, native amd64+arm64) / Build & push (amd64) [native] (push) Has been cancelled
Publish Docker image (Multi Registries, native amd64+arm64) / Build & push (arm64) [native] (push) Has been cancelled
Publish Docker image (Multi Registries, native amd64+arm64) / Create multi-arch manifests (Docker Hub) (push) Has been cancelled
Build Electron App / build (windows-latest) (push) Has been cancelled
Build Electron App / release (push) Has been cancelled
Release (Linux, macOS, Windows) / Linux Release (push) Has been cancelled
Release (Linux, macOS, Windows) / macOS Release (push) Has been cancelled
Release (Linux, macOS, Windows) / Windows Release (push) Has been cancelled

fix: 修复 失败后不重试 配置项写到内存被覆盖
This commit is contained in:
Calcium-Ion 2026-04-08 15:45:02 +08:00 committed by GitHub
commit 9b4ffb0875
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 49 additions and 33 deletions

View File

@ -20,7 +20,7 @@ type ChannelAffinityRule struct {
ParamOverrideTemplate map[string]interface{} `json:"param_override_template,omitempty"` ParamOverrideTemplate map[string]interface{} `json:"param_override_template,omitempty"`
SkipRetryOnFailure bool `json:"skip_retry_on_failure,omitempty"` SkipRetryOnFailure bool `json:"skip_retry_on_failure"`
IncludeUsingGroup bool `json:"include_using_group"` IncludeUsingGroup bool `json:"include_using_group"`
IncludeModelName bool `json:"include_model_name"` IncludeModelName bool `json:"include_model_name"`

View File

@ -192,6 +192,36 @@ const parseOptionalObjectJson = (jsonString, label) => {
} }
}; };
const buildChannelAffinityRulePayload = ({
values,
isEdit,
editingRuleId,
rulesLength,
modelRegex,
pathRegex,
keySources,
userAgentInclude,
paramOverrideTemplate,
}) => ({
id: isEdit ? editingRuleId : rulesLength,
name: (values?.name || '').trim(),
model_regex: modelRegex,
path_regex: pathRegex,
key_sources: keySources,
value_regex: (values?.value_regex || '').trim(),
ttl_seconds: Number(values?.ttl_seconds || 0),
include_using_group: !!values?.include_using_group,
include_model_name: !!values?.include_model_name,
include_rule_name: !!values?.include_rule_name,
skip_retry_on_failure: !!values?.skip_retry_on_failure,
...(userAgentInclude.length > 0
? { user_agent_include: userAgentInclude }
: {}),
...(paramOverrideTemplate
? { param_override_template: paramOverrideTemplate }
: {}),
});
export default function SettingsChannelAffinity(props) { export default function SettingsChannelAffinity(props) {
const { t } = useTranslation(); const { t } = useTranslation();
const { Text } = Typography; const { Text } = Typography;
@ -456,14 +486,12 @@ export default function SettingsChannelAffinity(props) {
const templates = [ const templates = [
CHANNEL_AFFINITY_RULE_TEMPLATES.codexCli, CHANNEL_AFFINITY_RULE_TEMPLATES.codexCli,
CHANNEL_AFFINITY_RULE_TEMPLATES.claudeCli, CHANNEL_AFFINITY_RULE_TEMPLATES.claudeCli,
].map( ].map((tpl) => {
(tpl) => { const baseTemplate = cloneChannelAffinityTemplate(tpl);
const baseTemplate = cloneChannelAffinityTemplate(tpl); const name = makeUniqueName(existingNames, tpl.name);
const name = makeUniqueName(existingNames, tpl.name); existingNames.add(name);
existingNames.add(name); return { ...baseTemplate, name };
return { ...baseTemplate, name }; });
},
);
const next = [...(rules || []), ...templates].map((r, idx) => ({ const next = [...(rules || []), ...templates].map((r, idx) => ({
...(r || {}), ...(r || {}),
@ -716,27 +744,17 @@ export default function SettingsChannelAffinity(props) {
return showError(t(paramTemplateValidation.message)); return showError(t(paramTemplateValidation.message));
} }
const rulePayload = { const rulePayload = buildChannelAffinityRulePayload({
id: isEdit ? editingRule.id : rules.length, values,
name: (values.name || '').trim(), isEdit,
model_regex: modelRegex, editingRuleId: editingRule?.id,
path_regex: normalizeStringList(values.path_regex_text), rulesLength: rules.length,
key_sources: keySourcesValidation.value, modelRegex,
value_regex: (values.value_regex || '').trim(), pathRegex: normalizeStringList(values.path_regex_text),
ttl_seconds: Number(values.ttl_seconds || 0), keySources: keySourcesValidation.value,
include_using_group: !!values.include_using_group, userAgentInclude,
include_model_name: !!values.include_model_name, paramOverrideTemplate: paramTemplateValidation.value,
include_rule_name: !!values.include_rule_name, });
...(values.skip_retry_on_failure
? { skip_retry_on_failure: true }
: {}),
...(userAgentInclude.length > 0
? { user_agent_include: userAgentInclude }
: {}),
...(paramTemplateValidation.value
? { param_override_template: paramTemplateValidation.value }
: {}),
};
if (!rulePayload.name) return showError(t('名称不能为空')); if (!rulePayload.name) return showError(t('名称不能为空'));
@ -1273,9 +1291,7 @@ export default function SettingsChannelAffinity(props) {
label={t('作用域:包含模型名称')} label={t('作用域:包含模型名称')}
/> />
<Text type='tertiary' size='small'> <Text type='tertiary' size='small'>
{t( {t('开启后,模型名称会参与 cache key不同模型隔离。')}
'开启后,模型名称会参与 cache key不同模型隔离。',
)}
</Text> </Text>
</Col> </Col>
<Col xs={24} sm={8}> <Col xs={24} sm={8}>