fix(ai): フォールバックモデルをgemini-2.0-flash(廃止)→gemini-2.5-flash-liteに変更
gemini-2.0-flashはdeprecated済みで、primary(gemini-2.5-flash)が3回失敗した際に 廃止済みモデルへ落ちて確実にエラーになっていた。フォールバックを現役の gemini-2.5-flash-liteに変更することで「解析に失敗しました」を解消する。 また、エラーメッセージにHTTPステータスコード等の短い補足を追加し、 次回の障害診断を容易にする(例: [404] [key?] [timeout])。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
778d2a725a
commit
856e349848
|
|
@ -381,9 +381,10 @@ mixin CameraAnalysisMixin<T extends ConsumerStatefulWidget> on ConsumerState<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
debugPrint('Analysis error: $e');
|
debugPrint('Analysis error: $e');
|
||||||
|
final errDetail = _extractErrorCode(e.toString());
|
||||||
messenger.showSnackBar(
|
messenger.showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: const Text('解析に失敗しました。時間をおいて再試行してください。'),
|
content: Text('解析に失敗しました。時間をおいて再試行してください。$errDetail'),
|
||||||
duration: const Duration(seconds: 5),
|
duration: const Duration(seconds: 5),
|
||||||
backgroundColor: appColors.error,
|
backgroundColor: appColors.error,
|
||||||
),
|
),
|
||||||
|
|
@ -395,6 +396,23 @@ mixin CameraAnalysisMixin<T extends ConsumerStatefulWidget> on ConsumerState<T>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// エラー文字列から HTTP ステータスコードや既知キーワードを抽出して表示用の短い補足を返す。
|
||||||
|
/// ユーザーが画面を見たときに「どのエラーか」を把握できるようにするため。
|
||||||
|
String _extractErrorCode(String err) {
|
||||||
|
final patterns = {
|
||||||
|
RegExp(r'\b(4\d{2}|5\d{2})\b'): (Match m) => ' [${m.group(0)}]',
|
||||||
|
RegExp(r'API_KEY_INVALID|PERMISSION_DENIED'): (_) => ' [key?]',
|
||||||
|
RegExp(r'RESOURCE_EXHAUSTED'): (_) => ' [quota]',
|
||||||
|
RegExp(r'NOT_FOUND'): (_) => ' [model?]',
|
||||||
|
RegExp(r'timeout', caseSensitive: false): (_) => ' [timeout]',
|
||||||
|
};
|
||||||
|
for (final entry in patterns.entries) {
|
||||||
|
final m = entry.key.firstMatch(err);
|
||||||
|
if (m != null) return entry.value(m);
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
/// さけのわ自動マッチング処理
|
/// さけのわ自動マッチング処理
|
||||||
///
|
///
|
||||||
/// 登録後にバックグラウンドで実行。
|
/// 登録後にバックグラウンドで実行。
|
||||||
|
|
|
||||||
|
|
@ -484,7 +484,7 @@ name・brand を出力する直前に以下を確認してください:
|
||||||
}
|
}
|
||||||
|
|
||||||
const primaryModel = 'gemini-2.5-flash';
|
const primaryModel = 'gemini-2.5-flash';
|
||||||
const fallbackModel = 'gemini-2.0-flash';
|
const fallbackModel = 'gemini-2.5-flash-lite';
|
||||||
|
|
||||||
final promptText = customPrompt ?? _mainAnalysisPrompt;
|
final promptText = customPrompt ?? _mainAnalysisPrompt;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
# In Windows, build-name is used as the major, minor, and patch parts
|
# In Windows, build-name is used as the major, minor, and patch parts
|
||||||
# of the product and file versions while build-number is used as the build suffix.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 1.0.48+55
|
version: 1.0.49+56
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ^3.10.1
|
sdk: ^3.10.1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue