fix(ui-model-selection,llm-deepseek): prioritize account models and simplify provider label
This commit is contained in:
1 parent
cc478ac70a
commit
325e28bfa0
9 files changed
+43
-15
No files matched your search
@@ -2,5 +2,5 @@
|
||||
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
||||
# after editing either side, bring the other along and re-record with:
|
||||
# pnpm run verify-translation-pairing --write packages/client/ui-model-selection/README.md
|
||||
README.md: 7afc8f158509e18e90236d6302ab51125fa7a891
|
||||
README.zh.md: c14ad7ab05af24c35727d42e6d843cbdaf20f332
|
||||
README.md: 9b73298b776d2f3d869a5da88db8d17e14f0f3a9
|
||||
README.zh.md: 4dbd077a30cbbaaefd9fabcbf1cc4661367a3069
|
||||
@@ -31,7 +31,7 @@ Mount this plugin alongside `ui-conversation` and the commands package; the comp
|
||||
|
||||
### Model and effort
|
||||
|
||||
Models stay grouped by provider. The composer menu shows model and effort names only. The `/model` popup shows provider names and catalog descriptions; it localizes the two built-in DeepSeek descriptions and leaves external provider descriptions verbatim. The popup applies the selected model's default effort; the composer can then choose any advertised effort. An adapter without reasoning metadata leaves the Effort row absent; there is no arbitrary effort input.
|
||||
Models stay grouped by provider. The composer menu shows model and effort names only, with DeepSeek Account first; other providers retain their catalog order. The `/model` popup shows provider names and catalog descriptions; it localizes the two built-in DeepSeek descriptions and leaves external provider descriptions verbatim. The popup applies the selected model's default effort; the composer can then choose any advertised effort. An adapter without reasoning metadata leaves the Effort row absent; there is no arbitrary effort input.
|
||||
|
||||
### Unroutable sessions
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ DeepSeek 账号和 API Key 路由显示为独立提供方分组,各自展示
|
||||
|
||||
### 模型与推理强度
|
||||
|
||||
模型按提供方分组。composer 菜单只显示模型与推理强度名称。`/model` 弹窗显示提供方名称与目录说明;其中两个内置 DeepSeek 模型的说明使用当前语言,外部提供方说明保持原文。弹窗应用所选模型的默认推理强度;composer 随后可以选择任一已公布的推理强度。适配器没有推理元数据时不显示 Effort 行;不存在任意推理强度输入。
|
||||
模型按提供方分组。composer 菜单只显示模型与推理强度名称,DeepSeek 账号置顶,其他提供方保持目录原有顺序。`/model` 弹窗显示提供方名称与目录说明;其中两个内置 DeepSeek 模型的说明使用当前语言,外部提供方说明保持原文。弹窗应用所选模型的默认推理强度;composer 随后可以选择任一已公布的推理强度。适配器没有推理元数据时不显示 Effort 行;不存在任意推理强度输入。
|
||||
|
||||
### 不可路由的会话
|
||||
|
||||
|
||||
@@ -75,7 +75,9 @@ export function ModelSelect(
|
||||
const itemRefs = useRef<(HTMLButtonElement | null)[]>([])
|
||||
const id = useId()
|
||||
|
||||
const choices = useMemo(() => state.groups.flatMap(group =>
|
||||
const groups = useMemo(() => state.groups.toSorted((left, right) =>
|
||||
Number(right.id === 'deepseek-account') - Number(left.id === 'deepseek-account')), [state.groups])
|
||||
const choices = useMemo(() => groups.flatMap(group =>
|
||||
group.models.map(model => ({
|
||||
group,
|
||||
model,
|
||||
@@ -86,7 +88,7 @@ export function ModelSelect(
|
||||
? {}
|
||||
: { reasoningEffort: model.reasoning.defaultEffort },
|
||||
} satisfies ModelSelection,
|
||||
}))), [state.groups])
|
||||
}))), [groups])
|
||||
const selectedIndex = state.current === null
|
||||
? -1
|
||||
: choices.findIndex(c => c.selection.provider === state.current?.provider && c.selection.model === state.current.model)
|
||||
@@ -409,7 +411,7 @@ export function ModelSelect(
|
||||
</div>
|
||||
))}
|
||||
<div className={clsx(css.groups, 'scrollable')}>
|
||||
{state.groups.map((group) => {
|
||||
{groups.map((group) => {
|
||||
const headingId = `${id}-${group.id}`
|
||||
return (
|
||||
<section role="group" aria-labelledby={headingId} className={css.group} key={group.id}>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
deepseek-account-1
|
||||
deepseek-account-2
|
||||
custom-1
|
||||
custom-2
|
||||
deepseek-official-1
|
||||
deepseek-official-2
|
||||
another-1
|
||||
another-2
|
||||
@@ -455,3 +455,21 @@ it('shows the unselected model control without a stale model or effort', async (
|
||||
await expect(`${trigger.textContent}\n`).toMatchFileSnapshot('./expected/unselected-model.txt')
|
||||
expect(trigger.textContent).not.toContain('High')
|
||||
})
|
||||
|
||||
|
||||
it('places account models first while preserving other provider and model order', async () => {
|
||||
const groups = ['custom', 'deepseek-official', 'deepseek-account', 'another'].map(id => ({
|
||||
id, name: id, models: [1, 2].map(index => ({ id: `${id}-${index}`, name: `${id}-${index}` })),
|
||||
}))
|
||||
const directory = createSnapshotStore<ModelDirectoryState>(state({ current: null, groups }))
|
||||
render(<ModelSelect locked={false} available directory={directory} load={vi.fn()} select={vi.fn()} t={t} />)
|
||||
fireEvent.click(screen.getByRole('button', { name: '请选择模型' }))
|
||||
fireEvent.click(screen.getByRole('menuitem', { name: /模型/ }))
|
||||
const names = screen.getAllByRole('menuitemradio').map(row => row.textContent)
|
||||
expect(names).toEqual([
|
||||
'deepseek-account-1', 'deepseek-account-2', 'custom-1', 'custom-2',
|
||||
'deepseek-official-1', 'deepseek-official-2', 'another-1', 'another-2',
|
||||
])
|
||||
expect(groups.map(group => group.id)).toEqual(['custom', 'deepseek-official', 'deepseek-account', 'another'])
|
||||
await expect(`${names.join('\n')}\n`).toMatchFileSnapshot('./expected/account-first.txt')
|
||||
})
|
||||
@@ -41,7 +41,7 @@ export class DeepSeekAdapter extends LlmAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
override providerInfo(provider: string) { return { id: provider, name: provider === 'deepseek-account' ? 'DeepSeek Account' : 'DeepSeek (API Key)' } }
|
||||
override providerInfo(provider: string) { return { id: provider, name: provider === 'deepseek-account' ? 'DeepSeek Account' : 'DeepSeek' } }
|
||||
override providerRetryPolicy(provider: string) { return this.implementation().providerRetryPolicy(provider) }
|
||||
override async listModels(provider: string) {
|
||||
try { await this.dependencies.resolveApiKey(this.dependencies.options()) }
|
||||
|
||||
@@ -133,7 +133,7 @@ export function apply(ctx: Context, config: Config): void {
|
||||
},
|
||||
})
|
||||
ctx.llm.registerConfigurableProviders([
|
||||
{ provider: PROVIDER, displayName: 'DeepSeek (API Key)', settingsNs: NS, settingsPath: [] },
|
||||
{ provider: PROVIDER, displayName: 'DeepSeek', settingsNs: NS, settingsPath: [] },
|
||||
{ provider: 'deepseek-account', displayName: 'DeepSeek Account', settingsNs: NS, settingsPath: [] },
|
||||
])
|
||||
// Route effects bind to this apply fiber via the stable `ctx` reference,
|
||||
|
||||
@@ -1697,10 +1697,10 @@ describe('plugin registration and config', () => {
|
||||
protocol: 'chat-completions',
|
||||
baseURL: server.url,
|
||||
})
|
||||
expect(ctx.llm.listProviders()).toEqual([{ id: 'deepseek-official', name: 'DeepSeek (API Key)' }, { id: 'deepseek-account', name: 'DeepSeek Account' }])
|
||||
expect(ctx.llm.listProviders()).toEqual([{ id: 'deepseek-official', name: 'DeepSeek' }, { id: 'deepseek-account', name: 'DeepSeek Account' }])
|
||||
expect(ctx.llm.listConfigurableProviders()).toEqual([{
|
||||
provider: 'deepseek-official',
|
||||
displayName: 'DeepSeek (API Key)',
|
||||
displayName: 'DeepSeek',
|
||||
settingsNs: 'llm-deepseek',
|
||||
settingsPath: [],
|
||||
}, { provider: 'deepseek-account', displayName: 'DeepSeek Account', settingsNs: 'llm-deepseek', settingsPath: [] }])
|
||||
@@ -1734,7 +1734,7 @@ describe('plugin registration and config', () => {
|
||||
const ctx = new Context()
|
||||
await ctx.plugin(LlmRuntime)
|
||||
await ctx.plugin(LlmDeepSeek, { protocol: 'chat-completions', baseURL: 'http://127.0.0.1:1' })
|
||||
expect(ctx.llm.listProviders()).toEqual([{ id: 'deepseek-official', name: 'DeepSeek (API Key)' }, { id: 'deepseek-account', name: 'DeepSeek Account' }])
|
||||
expect(ctx.llm.listProviders()).toEqual([{ id: 'deepseek-official', name: 'DeepSeek' }, { id: 'deepseek-account', name: 'DeepSeek Account' }])
|
||||
await expect(ctx.llm.listModels('deepseek-official')).resolves.toEqual([
|
||||
{ provider: 'deepseek-official', id: 'deepseek-flash', name: 'DeepSeek-V41-Flash', inputModalities: ['text', 'image'] },
|
||||
{
|
||||
@@ -2189,7 +2189,7 @@ describe('plugin registration and config', () => {
|
||||
const ctx = new Context()
|
||||
await ctx.plugin(LlmRuntime)
|
||||
await ctx.plugin(LlmDeepSeek, { protocol: 'chat-completions' })
|
||||
expect(ctx.llm.listProviders()).toEqual([{ id: 'deepseek-official', name: 'DeepSeek (API Key)' }, { id: 'deepseek-account', name: 'DeepSeek Account' }])
|
||||
expect(ctx.llm.listProviders()).toEqual([{ id: 'deepseek-official', name: 'DeepSeek' }, { id: 'deepseek-account', name: 'DeepSeek Account' }])
|
||||
})
|
||||
|
||||
it('loads keyless, hides unavailable models, and fails the request actionably', async () => {
|
||||
@@ -2198,7 +2198,7 @@ describe('plugin registration and config', () => {
|
||||
await ctx.plugin(LlmRuntime)
|
||||
await ctx.plugin(LlmDeepSeek, { protocol: 'chat-completions', baseURL: 'http://127.0.0.1:1' })
|
||||
// The registered provider remains configurable before its credential exists.
|
||||
expect(ctx.llm.listProviders()).toEqual([{ id: 'deepseek-official', name: 'DeepSeek (API Key)' }, { id: 'deepseek-account', name: 'DeepSeek Account' }])
|
||||
expect(ctx.llm.listProviders()).toEqual([{ id: 'deepseek-official', name: 'DeepSeek' }, { id: 'deepseek-account', name: 'DeepSeek Account' }])
|
||||
await expect(ctx.llm.listModels('deepseek-official')).resolves.toHaveLength(0)
|
||||
const first = await assemble(ctx, { model: 'deepseek-flash', messages: [] })
|
||||
expect(first.finish).toMatchObject({ kind: 'error', failure: { code: 'MISSING_CREDENTIAL' } })
|
||||
@@ -2279,7 +2279,7 @@ describe('plugin registration and config', () => {
|
||||
await ctx.plugin(LlmRuntime)
|
||||
// Registration succeeds; no call is made (would hit api.deepseek.com).
|
||||
await ctx.plugin(LlmDeepSeek, { protocol: 'chat-completions' })
|
||||
expect(ctx.llm.listProviders()).toEqual([{ id: 'deepseek-official', name: 'DeepSeek (API Key)' }, { id: 'deepseek-account', name: 'DeepSeek Account' }])
|
||||
expect(ctx.llm.listProviders()).toEqual([{ id: 'deepseek-official', name: 'DeepSeek' }, { id: 'deepseek-account', name: 'DeepSeek Account' }])
|
||||
})
|
||||
|
||||
it('adapter is constructible directly for embedding over the shared resolver', async () => {
|
||||
|
||||
Reference in new issue
Block a user