🔧 Offer gateway model names without the [1m] suffix in the project model catalog

This commit is contained in:
wishforge 2026-11-09 01:23:38 -08:00
parent 59238e5e82
commit aa4915b214
7 changed files with 26 additions and 34 deletions

View File

@ -305,7 +305,7 @@ export function ProjectSettings({
) : null}
<Field
label="可用模型"
hint={`勾选许愿时可选用的模型。默认用 deepseek-flash@latest[1m];未勾选则用执行器的默认模型。${capabilities.data?.modelCatalog ? '展开后点「获取模型」可列出网关提供的全部模型。' : ''}`}
hint={`勾选许愿时可选用的模型。默认用 deepseek-flash@latest;未勾选则用执行器的默认模型。${capabilities.data?.modelCatalog ? '展开后点「获取模型」可列出网关提供的全部模型。' : ''}`}
>
<ModelPicker value={models} onChange={setModels} canFetch={capabilities.data?.modelCatalog} />
</Field>

View File

@ -641,7 +641,7 @@ export function NewWishView() {
</select>
</Field>
{projectModels.length ? (
<Field label="模型" hint="项目管理员在项目设置里指定可选的模型,默认用 deepseek-flash@latest[1m]。">
<Field label="模型" hint="项目管理员在项目设置里指定可选的模型,默认用 deepseek-flash@latest。">
<select value={model} onChange={event => setModel(event.target.value)}>
{orderProjectModels(projectModels).map(name => (
<option key={name} value={name}>

View File

@ -101,7 +101,7 @@ WishForge 的所有重度投入,全部集中在第二类工程中。
- 系统将调用高响应模型,结合项目特有的规约规则,将其自动整理为工业级规范草案。
### 3. 智能模型选择与动态模型获取
- **默认模型策略**:项目默认优先选用经过深度验证的 `deepseek-flash@latest[1m]`,在确保推理精度的同时最大化响应速度与节省 Token 额度。
- **默认模型策略**:项目默认优先选用经过深度验证的 `deepseek-flash@latest`,在确保推理精度的同时最大化响应速度与节省 Token 额度。
- **获取最新模型**:
- 项目管理员进入 **「项目空间 $\rightarrow$ 项目设置」**;
- 展开「可用模型」下拉框,点击 **「获取模型」** 按钮;
@ -208,8 +208,8 @@ WishForge 内部定义了 16 种结构化等待原因(`WaitingReason`),坚
**解答**:
- **根本原因**:AI 优化愿望是一次短耗时、高约束的自然语言转结构化 JSON 操作。过去系统默认继承了编码用的大参数模型(`deepseek-pro`),该模型在输出长规范 JSON 时耗时易打穿默认的 120 秒命令行超时,进而导致网关返回 502。
- **平台当前防御与兜底体系**:
1. **首选轻量模型**:默认优化通道调整为秒级响应的轻量模型 `deepseek-flash@latest[1m]`。
2. **双模型自动降级(Fallback)**:若 Flash 模型偶发超时或返回畸变格式,后端会自动无缝切换至 `deepseek-pro@latest[1m]` 进行二次重试。
1. **首选轻量模型**:默认优化通道调整为秒级响应的轻量模型 `deepseek-flash@latest`。
2. **双模型自动降级(Fallback)**:若 Flash 模型偶发超时或返回畸变格式,后端会自动无缝切换至 `deepseek-pro@latest` 进行二次重试。
3. **超时全链路放宽**:单次模型命令超时放宽至 180 秒,Web 反向代理等待超时扩展至 400 秒,为双模型重试留足安全边际。
---
@ -225,6 +225,6 @@ WishForge 内部定义了 16 种结构化等待原因(`WaitingReason`),坚
### Q6: 可用模型为什么由原来的手输文本框改成了下拉勾选与动态拉取?
**解答**:
- **根本原因与优势**:
1. **规避人工输入错误**:过去手输模式容易发生大小写错误、特殊字符错漏或漏写上下文后缀(如 `[1m]` 后缀是驱动 Claude CLI 正确分配 100 万长上下文窗口的关键标识)。
2. **白名单与受控交付**:项目管理员通过下拉复选框严格限定该项目允许使用的模型范围(默认勾选 `deepseek-flash@latest[1m]` 和 `deepseek-pro@latest[1m]`)。
1. **规避人工输入错误**:过去手输模式容易发生大小写错误、特殊字符错漏等问题。默认模型名统一用网关别名,不带 `[1m]` 后缀。
2. **白名单与受控交付**:项目管理员通过下拉复选框严格限定该项目允许使用的模型范围(默认勾选 `deepseek-flash@latest` 和 `deepseek-pro@latest`)。
3. **实时动态同步**:内置 **「获取模型」** 按钮,管理员可在界面上一键直接向公司模型网关查询最新上架的模型列表,即点即用,兼顾灵活性与企业合规管控。

View File

@ -524,11 +524,11 @@ export const skillUpdateInput = z
})
.strict()
.refine(value => Object.values(value).some(field => field !== undefined), 'Change at least one field');
/** A model name as an executor or gateway spells it, such as `deepseek-pro@latest[1m]` or `gpt-5.4`. */
/** A model name as an executor or gateway spells it, such as `deepseek-pro@latest` or `gpt-5.4`. */
export const modelName = z
.string()
.trim()
.regex(/^[A-Za-z0-9][A-Za-z0-9_.:/@[\]-]{0,159}$/, 'Use a model name such as deepseek-pro@latest[1m]');
.regex(/^[A-Za-z0-9][A-Za-z0-9_.:/@[\]-]{0,159}$/, 'Use a model name such as deepseek-pro@latest');
export {
knownModels,
isKnownModel,

View File

@ -5,9 +5,9 @@ export const MAX_PROJECT_MODELS = 20;
/**
* Models the settings page offers. A wish defaults to the first of these the project
* enables (`deepseek-flash@latest[1m]`), else the first name the project lists.
* enables (`deepseek-flash@latest`), else the first name the project lists.
*/
export const knownModels = ['deepseek-flash@latest[1m]', 'deepseek-pro@latest[1m]'] as const;
export const knownModels = ['deepseek-flash@latest', 'deepseek-pro@latest'] as const;
export type KnownModel = (typeof knownModels)[number];
export const isKnownModel = (name: string): name is KnownModel => (knownModels as readonly string[]).includes(name);
/** Selected models in catalog order, then any name the catalog does not list. */

View File

@ -4,13 +4,7 @@ import { MAX_RUN_TOKENS, budgetSchema, countedTokens, modelName, projectModelsIn
describe('model names a project may offer', () => {
it('accepts names as executors and the model gateway spell them', () => {
for (const name of [
'deepseek-pro@latest[1m]',
'deepseek-flash@latest',
'gpt-5.4',
'claude-sonnet-4-5',
'org/model:v2',
])
for (const name of ['deepseek-pro@latest', 'deepseek-flash@latest', 'gpt-5.4', 'claude-sonnet-4-5', 'org/model:v2'])
expect(modelName.parse(name)).toBe(name);
expect(modelName.parse(' deepseek-pro@latest ')).toBe('deepseek-pro@latest');
});
@ -24,21 +18,19 @@ describe('model names a project may offer', () => {
expect(projectModelsInput.safeParse(Array.from({ length: 21 }, (_, i) => `m${i}`)).success).toBe(false);
});
it('lets a wish name a model', () => {
expect(wishInput.parse({ goal: 'g', acceptanceCriteria: ['c'], model: 'deepseek-flash@latest[1m]' }).model).toBe(
'deepseek-flash@latest[1m]',
expect(wishInput.parse({ goal: 'g', acceptanceCriteria: ['c'], model: 'deepseek-flash@latest' }).model).toBe(
'deepseek-flash@latest',
);
});
it('lists flash before pro, and a wish defaults to flash when the project offers it', () => {
expect([...knownModels]).toEqual(['deepseek-flash@latest[1m]', 'deepseek-pro@latest[1m]']);
expect(orderProjectModels(['deepseek-pro@latest[1m]', 'deepseek-flash@latest[1m]', 'gpt-5.4'])).toEqual([
'deepseek-flash@latest[1m]',
'deepseek-pro@latest[1m]',
expect([...knownModels]).toEqual(['deepseek-flash@latest', 'deepseek-pro@latest']);
expect(orderProjectModels(['deepseek-pro@latest', 'deepseek-flash@latest', 'gpt-5.4'])).toEqual([
'deepseek-flash@latest',
'deepseek-pro@latest',
'gpt-5.4',
]);
expect(defaultProjectModel(['deepseek-pro@latest[1m]', 'deepseek-flash@latest[1m]'])).toBe(
'deepseek-flash@latest[1m]',
);
expect(defaultProjectModel(['deepseek-pro@latest[1m]'])).toBe('deepseek-pro@latest[1m]');
expect(defaultProjectModel(['deepseek-pro@latest', 'deepseek-flash@latest'])).toBe('deepseek-flash@latest');
expect(defaultProjectModel(['deepseek-pro@latest'])).toBe('deepseek-pro@latest');
expect(defaultProjectModel([])).toBeUndefined();
});
});

View File

@ -1396,23 +1396,23 @@ describe('local main loop', () => {
// A project without models leaves the model to the executor: there is nothing to choose.
await expect(
submit(project.id, 'Make the greeting say hello world', 'wish-model-0001', {
model: 'deepseek-flash@latest[1m]',
model: 'deepseek-flash@latest',
}),
).rejects.toMatchObject({ code: 'MODEL_NOT_ALLOWED' });
await store.transaction(TENANT, async tx => {
const current = (await tx.get<Project>('project', project.id))!;
await tx.put('project', { ...current, models: ['deepseek-pro@latest[1m]', 'deepseek-flash@latest[1m]'] });
await tx.put('project', { ...current, models: ['deepseek-pro@latest', 'deepseek-flash@latest'] });
});
const byDefault = await submit(project.id, 'Make the greeting say hello world', 'wish-model-0002');
expect(await services.control.run(owner, byDefault)).toMatchObject({ providerModel: 'deepseek-flash@latest[1m]' });
expect(await services.control.run(owner, byDefault)).toMatchObject({ providerModel: 'deepseek-flash@latest' });
await expect(
submit(project.id, 'Make the greeting say hello world', 'wish-model-0003', { model: 'gpt-5.4' }),
).rejects.toMatchObject({ code: 'MODEL_NOT_ALLOWED' });
const chosen = await submit(project.id, 'Make the greeting say hello world', 'wish-model-0004', {
model: 'deepseek-flash@latest[1m]',
model: 'deepseek-flash@latest',
});
const run = await services.control.run(owner, chosen);
expect(run.providerModel).toBe('deepseek-flash@latest[1m]');
expect(run.providerModel).toBe('deepseek-flash@latest');
expect(run).not.toHaveProperty('model');
// The executor starts the agent with the model the run pinned.
let started: string | undefined;
@ -1421,7 +1421,7 @@ describe('local main loop', () => {
return writeGreeting('hello world', 'Completed the greeting.')(start);
});
await session.executor.executeRun(session.input);
expect(started).toBe('deepseek-flash@latest[1m]');
expect(started).toBe('deepseek-flash@latest');
});
it('keeps an account that may only wish for frontend changes to frontend code', async () => {
const project = await createProject();