fix(data-process): 完善默认生成提示语

This commit is contained in:
caoxiaozhu
2026-07-27 14:58:02 +08:00
parent f97245b814
commit 4623e3fa1c
3 changed files with 31 additions and 5 deletions

View File

@@ -514,8 +514,21 @@ assert.match(
/\.model-config-group \.advanced-settings-grid\s*\{[\s\S]*?grid-template-columns:\s*1fr/,
'大模型高级参数没有改为与第一步一致的纵向布局',
)
assert.match(stateSource, /const DEFAULT_STANDARD_GENERATION_PROMPT\s*=\s*['"][^'"]{40,}['"]/, '标准回答缺少独立默认提示语')
assert.match(stateSource, /const DEFAULT_REASONING_GENERATION_PROMPT\s*=\s*['"][^'"]{40,}['"]/, '思维链回答缺少独立默认提示语')
function defaultPromptValue(name) {
const match = stateSource.match(new RegExp(`export const ${name} = ` + '`([\\s\\S]*?)`'))
assert.ok(match, `${name} 缺少可编辑的内置默认提示语`)
return match[1]
}
const standardPrompt = defaultPromptValue('DEFAULT_STANDARD_GENERATION_PROMPT')
const reasoningPrompt = defaultPromptValue('DEFAULT_REASONING_GENERATION_PROMPT')
assert.ok(standardPrompt.includes('{{ content }}'), '标准回答默认提示语缺少 {{ content }} 占位符')
assert.ok(reasoningPrompt.includes('{{ content }}'), '思维链默认提示语缺少 {{ content }} 占位符')
assert.ok(standardPrompt.length <= 500, '标准回答默认提示语超过输入框长度限制')
assert.ok(reasoningPrompt.length <= 500, '思维链默认提示语超过输入框长度限制')
assert.ok(reasoningPrompt.includes('中间思考过程'), '思维链默认提示语没有明确要求生成中间思考过程')
assert.ok(reasoningPrompt.includes('不得跳过推理只给结论'), '思维链默认提示语没有禁止只生成最终答案')
assert.notEqual(standardPrompt, reasoningPrompt, '标准回答与思维链回答不得共用默认提示语')
assert.match(generationControlSource, /默认提示语已包含[\s\S]*?\{\{ content \}\}[\s\S]*?可移动该占位符/, '默认提示语没有说明 {{ content }} 的内置位置和修改方式')
assert.equal((stateSource.match(/generationPrompt:\s*DEFAULT_STANDARD_GENERATION_PROMPT/g) || []).length, 2, '结构化与非结构化任务应默认使用标准回答提示语')
assert.match(generationControlSource, /isBuiltInGenerationPrompt\(props\.options\.generationPrompt\)[\s\S]*?defaultGenerationPrompt\(outputType\)[\s\S]*?: props\.options\.generationPrompt/, '切换输出类型时没有在保留自定义提示语的前提下切换内置提示语')
assert.equal((stateSource.match(/^\s{4}outputType:\s*'standard',/gm) || []).length, 2, '结构化与非结构化任务应默认生成标准回答')