fix: AI 复习变式请求字段与校验一致;转写后删除不保留的录音

- generateReviewVariant 的指令要求 stimulus/answer/acceptedAnswers 等字段,
  而 decodeGeneratedReviewVariant 只接受 schemaVersion、variantId、
  targetItemId、prompt、expectedAnswer 五个字段,导致 AI 变式始终校验失败。
  现在指令只要求这五个字段,并补充了请求与解码一致性的测试。
- finishVoiceInput(keepAudio: false) 转写完成(或页面已关闭)后删除音频,
  补练页和测评页的语音输入不再在本机残留录音文件。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
shenlei
2026-09-16 17:29:56 +09:00
co-authored by Claude Opus 5
parent 29b1738162
commit 4d324903b4
3 changed files with 70 additions and 3 deletions
+9 -1
View File
@@ -780,7 +780,15 @@ class AiService {
}) async {
if (provider == AiProviderType.mock) return null;
final instruction =
'Generate one A0 English review variant for item $targetItemId based on prompt "$basePrompt". Return JSON only with exactly: schemaVersion (must be "review-variant-1"), targetItemId (must be "$targetItemId"), prompt (short Chinese instruction), stimulus (English sentence, maximum 12 words), answer (exact expected English answer, maximum 10 words), acceptedAnswers (array of 1 to 4 strings), requiredAnyPhrases (array of 1 to 3 arrays of strings), forbiddenPhrases (array of up to 4 strings). Stay strictly within A0. Do not introduce new vocabulary. The answer must satisfy the spec.${repairAttempt ? ' Previous response failed schema or constraint validation: repair all errors.' : ''}';
'Generate one A0 English review variant for item $targetItemId based on prompt "$basePrompt". '
'Return JSON only with exactly these five fields and nothing else: '
'schemaVersion (must be "review-variant-1"), '
'variantId (short id such as "ai-${targetItemId.toLowerCase()}-1", maximum 80 characters), '
'targetItemId (must be "$targetItemId"), '
'prompt (a new short Chinese situation asking the learner to say the same target expression, maximum 120 Chinese characters), '
'expectedAnswer (the English reference answer, maximum 12 words; use [place], [name] or [number] for learner-specific details). '
'Stay strictly within A0. Do not introduce new vocabulary or change the target expression.'
'${repairAttempt ? ' Previous response failed schema or constraint validation: repair all errors.' : ''}';
final content = await _requestPrompt(
provider: provider,
endpoint: endpoint,