Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions changelog/unreleased/aggregation-capability-overrides.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
### English

- Aggregated models can now pin the context window, max output tokens, reasoning levels, and default reasoning effort in the model pool editor; `/v1/models` advertises exactly those values.
- Aggregations without overrides advertise the conservative intersection of their members (smallest window and output, shared reasoning levels) instead of the first member's values, and members are resolved by provider and region rather than by model name alone.
- Requests that carry no reasoning intent use the aggregation's configured default level, and each member provider still maps or clamps the level to what its own model supports.

### 中文

- 聚合模型可在模型池编辑器中配置上下文窗口、最大输出、思考档位与默认思考强度,`/v1/models` 会按配置值对外声明。
- 未配置时聚合改为声明各成员保守的交集(最小窗口与输出、共有的思考档位),不再沿用第一个成员的数值;成员按供应商与区域精确解析,而不是只按模型名匹配。
- 未携带思考意图的请求会使用聚合配置的默认档位,每个成员的供应商仍按自身模型支持的档位做映射与钳制。
9 changes: 9 additions & 0 deletions changelog/unreleased/aggregation-key-model-list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### English

- Fix the key editor's cross-provider aggregation switch: while it is on, every provider checkbox under it is disabled and visibly greyed out instead of staying clickable, so a saved grant set cannot drift while the key is in provider-neutral mode.
- Fix an aggregation key returning an empty `/v1/models`: the key now lists the enabled logical models from the model pool plus the account aliases it can reach, still folded into provider-neutral names. The gateway also accepts those logical models on the chat path, not just account aliases, so a client that picks a listed model no longer gets `model_not_aggregated`.

### 中文

- 修复密钥编辑页的跨供应商聚合开关:开启后下方所有供应商复选框置灰且不可选择,避免密钥处于供应商中立模式时仍能改动已保存的供应商授权。
- 修复聚合密钥的 `/v1/models` 为空:现在会返回模型池里已启用的跨供应商聚合模型,以及这把密钥可访问账号上配置的公共别名,并继续折叠成不显示供应商的名称;网关在对话链路也会接受这些聚合模型(不再只认账号别名),客户端从列表选中模型后不会再收到 `model_not_aggregated`。
8 changes: 8 additions & 0 deletions frontend/src/api/modelPools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export type AggregationRecord = {
strategy: string
allow_fallbacks: boolean
max_attempts: number
context_length?: number
max_output_tokens?: number
reasoning_options?: string[]
reasoning_effort?: string
members: AggregationMember[]
created_at: string
updated_at: string
Expand All @@ -29,6 +33,10 @@ export type AggregationInput = {
strategy: string
allow_fallbacks?: boolean
max_attempts: number
context_length?: number
max_output_tokens?: number
reasoning_options?: string[]
reasoning_effort?: string
members: AggregationMember[]
}

Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/ui/FilterSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ export function FilterSelect({
ariaLabel,
options,
className,
isDisabled = false,
}: {
value: string
onChange: (value: string) => void
ariaLabel: string
options: FilterSelectOption[]
className?: string
isDisabled?: boolean
}) {
const items = options.map((option) => ({
id: option.id || ALL_VALUE,
Expand All @@ -33,6 +35,7 @@ export function FilterSelect({
className={className ?? 'w-fit min-w-36'}
aria-label={ariaLabel}
value={selectedId}
isDisabled={isDisabled}
onChange={(next) => {
if (typeof next !== 'string') return
onChange(next === ALL_VALUE ? '' : next)
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/i18n/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ export const messages: Record<Lang, Dict> = {
keysMaxInflightValue: 'Up to {count} at once',
keysMaxInflightUnlimited: 'No concurrency limit',
keysModelAggregation: 'Cross-provider aggregation',
keysModelAggregationHint: 'When on, /v1/models lists only the public model aliases configured on accounts this key can reach, merged into one provider-neutral name. Requests still route through the account pool.',
keysModelAggregationHint: 'When on, /v1/models lists the enabled models from the cross-provider model pool plus the public aliases this key can reach, merged into one provider-neutral name. Requests still route through the account pool. Provider selection is locked while this stays on.',
keysModelAggregationBadge: 'Aggregated',
keysLastUsed: 'Last used {time}',
keysNeverUsed: 'Not used yet',
Expand Down Expand Up @@ -2230,7 +2230,7 @@ export const messages: Record<Lang, Dict> = {
keysMaxInflightValue: '同时最多 {count} 条',
keysMaxInflightUnlimited: '不限制并发',
keysModelAggregation: '跨供应商模型聚合',
keysModelAggregationHint: '开启后,/v1/models 只返回这把密钥可访问账号上配置的公共模型别名,并按名称合并成一条、不显示供应商。请求仍按账号池路由。',
keysModelAggregationHint: '开启后,/v1/models 返回模型池里已启用的跨供应商聚合模型,以及这把密钥可访问账号上配置的公共别名,并按名称合并成一条、不显示供应商;请求仍按账号池路由。开启期间供应商选项锁定。',
keysModelAggregationBadge: '聚合',
keysLastUsed: '最近使用 {time}',
keysNeverUsed: '尚未使用',
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/pages/KeysPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,9 @@ function KeyEditorModal({
{options.map((option) => {
const checked = selected.includes(option.value)
const allRegions = allRegionsFamilies.has(option.provider)
const locked = busy || modelAggregation
return (
<Checkbox key={option.value} isSelected={checked} onChange={() => toggle(option.value)} className="rounded-xl bg-surface-secondary px-3 py-2.5 data-selected:border-accent data-selected:bg-accent-soft">
<Checkbox key={option.value} isSelected={checked} isDisabled={locked} onChange={() => toggle(option.value)} className={`rounded-xl bg-surface-secondary px-3 py-2.5 data-selected:border-accent data-selected:bg-accent-soft ${locked ? 'cursor-not-allowed opacity-50 grayscale' : ''}`}>
<Checkbox.Content className="flex items-center gap-2.5">
<Checkbox.Control>
<Checkbox.Indicator />
Expand Down
80 changes: 80 additions & 0 deletions frontend/src/pages/ModelPoolPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import { accountProviderLabel } from '@/lib/provider'
type TFunc = (key: string, vars?: Record<string, string | number>) => string
type AccountRow = NonNullable<Overview['accounts']>[number]

const REASONING_LEVELS = ['none', 'low', 'medium', 'high', 'xhigh', 'max'] as const

type MemberDraft = AggregationMember & { key: string }

function newMemberDraft(): MemberDraft {
Expand Down Expand Up @@ -303,6 +305,10 @@ function AggregationEditorModal({
const [strategy, setStrategy] = useState<string>('priority')
const [allowFallbacks, setAllowFallbacks] = useState(true)
const [maxAttempts, setMaxAttempts] = useState(3)
const [contextLength, setContextLength] = useState(0)
const [maxOutput, setMaxOutput] = useState(0)
const [reasoningOptions, setReasoningOptions] = useState<string[]>([])
const [reasoningEffort, setReasoningEffort] = useState('')
const [members, setMembers] = useState<MemberDraft[]>([])
const [error, setError] = useState('')
const [busy, setBusy] = useState(false)
Expand All @@ -314,6 +320,10 @@ function AggregationEditorModal({
setStrategy(initial?.strategy || 'priority')
setAllowFallbacks(initial?.allow_fallbacks ?? true)
setMaxAttempts(initial?.max_attempts ?? 3)
setContextLength(initial?.context_length ?? 0)
setMaxOutput(initial?.max_output_tokens ?? 0)
setReasoningOptions(initial?.reasoning_options ?? [])
setReasoningEffort(initial?.reasoning_effort ?? '')
setMembers((initial?.members || []).map((m) => ({ ...m, key: `${m.provider}-${m.model}-${Math.random()}` })))
setError('')
}, [initial, isOpen])
Expand All @@ -339,6 +349,14 @@ function AggregationEditorModal({
})
}

function toggleReasoningLevel(level: string) {
const next = reasoningOptions.includes(level)
? reasoningOptions.filter((item) => item !== level)
: [...reasoningOptions, level]
setReasoningOptions(next)
if (reasoningEffort && !next.includes(reasoningEffort)) setReasoningEffort('')
}

async function submit(event?: { preventDefault(): void }) {
event?.preventDefault()
if (!initial) {
Expand All @@ -351,6 +369,15 @@ function AggregationEditorModal({
if (!Number.isInteger(maxAttempts) || maxAttempts < 1 || maxAttempts > 64) {
setError(t('modelPoolAttemptsInvalid')); return
}
if (!Number.isInteger(contextLength) || contextLength < 0 || (contextLength > 0 && contextLength < 1024)) {
setError(t('modelPoolCapabilitiesInvalid')); return
}
if (!Number.isInteger(maxOutput) || maxOutput < 0 || (maxOutput > 0 && maxOutput < 1024) || (contextLength > 0 && maxOutput > contextLength)) {
setError(t('modelPoolCapabilitiesInvalid')); return
}
if (reasoningEffort && !reasoningOptions.includes(reasoningEffort)) {
setError(t('modelPoolReasoningInvalid')); return
}
setBusy(true)
setError('')
try {
Expand All @@ -359,6 +386,10 @@ function AggregationEditorModal({
strategy,
allow_fallbacks: allowFallbacks,
max_attempts: maxAttempts,
context_length: contextLength,
max_output_tokens: maxOutput,
reasoning_options: reasoningOptions,
reasoning_effort: reasoningEffort,
members: members.map((m, i) => ({
provider: m.provider,
region: m.region || '',
Expand Down Expand Up @@ -421,6 +452,55 @@ function AggregationEditorModal({
</div>
</FormRow>

<div className="space-y-3">
<div>
<Label className="text-body font-medium text-muted">{t('modelPoolCapabilities')}</Label>
<Description className="text-caption leading-5 text-muted">{t('modelPoolCapabilitiesHint')}</Description>
</div>
<div className="grid gap-3 sm:grid-cols-2">
<FormRow label={t('modelPoolContextLength')} hint={t('modelPoolContextLengthHint')} align="start">
<NumberField value={contextLength} onChange={(v) => setContextLength(v ?? 0)} minValue={0} maxValue={4000000} isDisabled={busy}>
<NumberField.Group>
<NumberField.DecrementButton />
<NumberField.Input aria-label={t('modelPoolContextLength')} />
<NumberField.IncrementButton />
</NumberField.Group>
</NumberField>
</FormRow>
<FormRow label={t('modelPoolMaxOutput')} hint={t('modelPoolMaxOutputHint')} align="start">
<NumberField value={maxOutput} onChange={(v) => setMaxOutput(v ?? 0)} minValue={0} maxValue={4000000} isDisabled={busy}>
<NumberField.Group>
<NumberField.DecrementButton />
<NumberField.Input aria-label={t('modelPoolMaxOutput')} />
<NumberField.IncrementButton />
</NumberField.Group>
</NumberField>
</FormRow>
</div>
<FormRow label={t('modelPoolReasoningLevels')} hint={t('modelPoolReasoningLevelsHint')} align="start">
<div className="flex flex-wrap gap-2">
{REASONING_LEVELS.map((level) => {
const selected = reasoningOptions.includes(level)
return (
<Button key={level} size="sm" variant={selected ? 'secondary' : 'ghost'} aria-pressed={selected} isDisabled={busy} onPress={() => toggleReasoningLevel(level)}>
<span className="mono">{level}</span>
</Button>
)
})}
</div>
</FormRow>
<FormRow label={t('modelPoolReasoningDefault')} hint={t('modelPoolReasoningDefaultHint')} align="start">
<FilterSelect
value={reasoningEffort}
onChange={setReasoningEffort}
ariaLabel={t('modelPoolReasoningDefault')}
options={[{ id: '', label: t('modelPoolReasoningAuto') }, ...reasoningOptions.map((level) => ({ id: level, label: level }))]}
className="w-full"
isDisabled={busy || reasoningOptions.length === 0}
/>
</FormRow>
</div>

<div className="space-y-3">
<div className="flex items-center justify-between gap-3">
<div>
Expand Down
Loading
Loading