feat: /api/score にZodスキーマ検証・JSON復旧・補正リトライを実装する#281
Open
keisato848 wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Issue #264 対応として、/api/score の AI 応答パースに Zod スキーマ検証、コードフェンス/前後文からの JSON 抽出、補正プロンプトによる最大 1 回のリトライを導入します。AI 呼び出しは callAi ヘルパーへ抽出され、初回・リトライで共用されます。__tests__/api/score.test.ts に 4 ケース(フェンス復旧/前後文復旧/補正リトライ成功/補正リトライ失敗)が追加されています。
Changes:
ScoringResultSchema/RadarDataSchemaを Zod で定義し、extractJson+parseAndValidateで復旧→検証- AI 呼び出しを
callAi関数へリファクタし、補正プロンプトbuildCorrectionPromptで 1 回だけリトライ - 復旧・補正パスを覆う 4 件のユニットテストを追加
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| apps/web/app/api/score/route.ts | Zod スキーマ・JSON 抽出・補正リトライ実装、AI 呼び出しを callAi に共通化 |
| apps/web/tests/api/score.test.ts | フェンス復旧/前後文復旧/補正リトライ成功/失敗の 4 ケース追加 |
✅ Staging デプロイ完了
|
288cdc9 to
07d2102
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
Issue #264 対応。/api/score のAI応答をZodでスキーマ検証し、JSON復旧・補正リトライを実装する。
変更内容
修正ファイル
受け入れ基準チェック
テスト
px tsc --noEmit エラーなし
Closes #264