flutterfire
flutterfire copied to clipboard
[firebase_ai]: Support for HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT and HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT in HarmCategory enum
Is there an existing issue for this?
- [x] I have searched the existing issues.
Which plugins are affected?
Other
Which platforms are affected?
Android, iOS, Web, Windows, macOS
Description
When attempting to override the built-in safety filters for image edits, I receive an Unhandled HarmCategory format error. The SDK’s HarmCategory enum currently lacks entries for HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT and HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT. How do we handle this?
Reproducing the issue
_editingModel = FirebaseAI.vertexAI().generativeModel( model: _remoteConfig.processingModel, safetySettings: [ SafetySetting( HarmCategory.sexuallyExplicit, HarmBlockThreshold.low, HarmBlockMethod.severity, ), SafetySetting( HarmCategory.dangerousContent, HarmBlockThreshold.low, HarmBlockMethod.severity, ), SafetySetting( HarmCategory.hateSpeech, HarmBlockThreshold.low, HarmBlockMethod.severity, ), SafetySetting( HarmCategory.harassment, HarmBlockThreshold.low, HarmBlockMethod.severity, ), ], generationConfig: GenerationConfig( temperature: _remoteConfig.processingTemperature, topK: 32, topP: 1, maxOutputTokens: _remoteConfig.processingMaxTokens, responseModalities: [ ResponseModalities.image, ResponseModalities.text, ], ), );
Firebase Core version
3.14.0
Flutter Version
3.32
Relevant Log Output
FormatException (FormatException: Unhandled HarmCategory format
HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT)
hashCode =
303418651
message =
"Unhandled HarmCategory format"
offset =
null
runtimeType =
Type (FormatException)
source =
"HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT"
Flutter dependencies
Expand Flutter dependencies snippet
name: fur_ar_ai
description: "A new Flutter project."
publish_to: "none"
version: 0.1.0
environment:
sdk: ^3.8.1
dependencies:
flutter:
sdk: flutter
flutter_localization: ^0.3.2
flutter_localizations:
sdk: flutter
image_picker: ^1.1.2
camera: ^0.11.1
dotted_border: ^2.0.0
cloud_firestore: ^5.6.9
firebase_core: ^3.14.0
firebase_storage: ^12.4.7
firebase_ai: ^2.1.0
firebase_remote_config: ^5.4.4
# firebase_auth: ^5.5.4
http: ^1.2.2
meta: ^1.16.0
flutter_riverpod: ^2.6.1
get_it: ^8.0.3
go_router: ^15.2.0
flutter_animate: ^4.5.2
icons_plus: ^5.0.0
json_serializable: ^6.9.5
logger: ^2.5.0
dio: ^5.8.0+1
flutter_dotenv: ^5.2.1
intl: ^0.20.2
flutter_native_splash: ^2.4.6
freezed_annotation: ^3.0.0
json_annotation: ^4.9.0
skeletonizer: ^2.0.1
dev_dependencies:
change_app_package_name: ^1.5.0
flutter_launcher_icons: ^0.14.4
asset_fill: ^2.0.0
build_runner: ^2.5.2
flutter_lints: ^6.0.0
flutter_test:
sdk: flutter
# Freezed code generation
freezed: ^3.0.6
flutter:
uses-material-design: true
generate: true
assets:
- assets/
- assets/brand/
# - assets/images/
# - myenv
fonts:
- family: Manrope
fonts:
- asset: assets/fonts/Manrope/Manrope-VariableFont_wght.ttf
- family: Nunito
fonts:
- asset: assets/fonts/Nunito/Nunito-VariableFont_wght.ttf
- asset: assets/fonts/Nunito/Nunito-Italic-VariableFont_wght.ttf
style: italic
- family: InstrumentSans
fonts:
- asset: assets/fonts/InstrumentSans/InstrumentSans-VariableFont_wdth,wght.ttf
- asset: assets/fonts/InstrumentSans/InstrumentSans-Italic-VariableFont_wdth,wght.ttf
style: italic
- family: SpaceGrotesk
fonts:
- asset: assets/fonts/SpaceGrotesk/SpaceGrotesk-VariableFont_wght.ttf
flutter_native_splash:
color: "#F1F1F1"
color_dark: "#F1F1F1"
image: assets/brand/app_icon.png
image_dark: assets/brand/app_icon.png
web: true
android_gravity: center
ios_content_mode: center
web_image_mode: center
flutter_launcher_icons:
android: "launcher_icon"
adaptive_icon_background: "#F1F1F1"
ios: true
background_color_ios: "#F1F1F1" # This adds a white background for iOS icons
remove_alpha_ios: true # This removes the alpha channel for iOS icons
image_path: assets/brand/app_icon.png # Use an opaque version
min_sdk_android: 21
Additional context and comments
This missing Enums must be add flutter package to.