feat(openai): port /responses/compact account support flow (PR #1555)

vansour/sub2api#1555 的 OpenAI compact 能力建模手工移植到当前 main:账号
级 compact 状态/auto-force_on-force_off 模式、compact-only 模型映射、调度器
tier 分层(已支持 > 未知 > 已知不支持)、管理后台 compact 主动探测,以及对应
i18n/状态徽章。普通 /responses 流量行为不变,无数据库迁移。
This commit is contained in:
shaw
2026-04-25 14:40:03 +08:00
parent b95ffce244
commit 095f457c57
32 changed files with 2534 additions and 189 deletions

View File

@@ -26,6 +26,13 @@ vi.mock('@/api/admin', () => ({
accounts: {
update: updateAccountMock,
checkMixedChannelRisk: checkMixedChannelRiskMock
},
settings: {
getWebSearchEmulationConfig: vi.fn().mockResolvedValue({ enabled: false, providers: [] }),
getSettings: vi.fn().mockResolvedValue({})
},
tlsFingerprintProfiles: {
list: vi.fn().mockResolvedValue([])
}
}
}))
@@ -82,6 +89,32 @@ const ModelWhitelistSelectorStub = defineComponent({
`
})
const SelectStub = defineComponent({
name: 'SelectStub',
props: {
modelValue: {
type: [String, Number, Boolean, null],
default: ''
},
options: {
type: Array,
default: () => []
}
},
emits: ['update:modelValue'],
template: `
<select
v-bind="$attrs"
:value="modelValue"
@change="$emit('update:modelValue', $event.target.value)"
>
<option v-for="option in options" :key="option.value" :value="option.value">
{{ option.label }}
</option>
</select>
`
})
function buildAccount() {
return {
id: 1,
@@ -119,7 +152,7 @@ function mountModal(account = buildAccount()) {
global: {
stubs: {
BaseDialog: BaseDialogStub,
Select: true,
Select: SelectStub,
Icon: true,
ProxySelector: true,
GroupSelector: true,
@@ -156,4 +189,31 @@ describe('EditAccountModal', () => {
'gpt-5.2': 'gpt-5.2'
})
})
it('submits OpenAI compact mode and compact-only model mapping', async () => {
const account = buildAccount()
account.extra = {
openai_compact_mode: 'force_on'
}
account.credentials = {
...account.credentials,
compact_model_mapping: {
'gpt-5.4': 'gpt-5.4-openai-compact'
}
}
updateAccountMock.mockReset()
checkMixedChannelRiskMock.mockReset()
checkMixedChannelRiskMock.mockResolvedValue({ has_risk: false })
updateAccountMock.mockResolvedValue(account)
const wrapper = mountModal(account)
await wrapper.get('form#edit-account-form').trigger('submit.prevent')
expect(updateAccountMock).toHaveBeenCalledTimes(1)
expect(updateAccountMock.mock.calls[0]?.[1]?.extra?.openai_compact_mode).toBe('force_on')
expect(updateAccountMock.mock.calls[0]?.[1]?.credentials?.compact_model_mapping).toEqual({
'gpt-5.4': 'gpt-5.4-openai-compact'
})
})
})