fix(ai): 2段階解析のバグ2件修正
- Stage1でname/brandが両方nullの場合は無意味なStage2をスキップして1段階フォールバック - nameJson/brandJsonをjsonEncode()でエスケープ(特殊文字含む銘柄名でのプロンプト破壊を防止) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
bcba78a533
commit
778d2a725a
|
|
@ -150,6 +150,12 @@ class GeminiService {
|
|||
return _callDirectApi(imagePaths, null, forceRefresh: forceRefresh);
|
||||
}
|
||||
|
||||
// Stage1 で name/brand が両方 null = ラベルを読めなかった → 2段階の意味なし
|
||||
if (ocr['name'] == null && ocr['brand'] == null) {
|
||||
debugPrint('Stage1 returned no text, falling back to single-stage');
|
||||
return _callDirectApi(imagePaths, null, forceRefresh: forceRefresh);
|
||||
}
|
||||
|
||||
// Stage 1 完了を UI に通知(AnalyzingDialog のメッセージを Stage2 用に切り替え)
|
||||
onStep1Complete?.call();
|
||||
|
||||
|
|
@ -225,9 +231,9 @@ class GeminiService {
|
|||
final brandConstraint = brand != null ? '「$brand」(確定済み — 変更禁止)' : 'null(確定済み)';
|
||||
final prefConstraint = prefecture != null ? '「$prefecture」(確定済み — 変更禁止)' : 'null(確定済み)';
|
||||
|
||||
final nameJson = name != null ? '"$name"' : 'null';
|
||||
final brandJson = brand != null ? '"$brand"' : 'null';
|
||||
final prefJson = prefecture != null ? '"$prefecture"' : 'null';
|
||||
final nameJson = name != null ? jsonEncode(name) : 'null';
|
||||
final brandJson = brand != null ? jsonEncode(brand) : 'null';
|
||||
final prefJson = prefecture != null ? jsonEncode(prefecture) : 'null';
|
||||
|
||||
return '''
|
||||
あなたは日本酒ラベル解析の専門家です。
|
||||
|
|
|
|||
Loading…
Reference in New Issue