You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using firebase_ai to generate images using Gemini, as in Firebase documentation.
The same instructions are supplied in Google Cloud - Vertex AI - Create prompt - Get code - Flutter:
import'dart:typed_data';
import'package:firebase_ai/firebase_ai.dart';
Future<void> generateContent() async {
final generationConfig =GenerationConfig(
maxOutputTokens:8192,
temperature:1,
topP:0.95,
);
final safetySettings = [
SafetySetting(
HarmCategory.hateSpeech,
HarmBlockThreshold./* TODO(developer): OFF is not supported by the SDK yet. */,
),
SafetySetting(
HarmCategory.dangerousContent,
HarmBlockThreshold./* TODO(developer): OFF is not supported by the SDK yet. */,
),
SafetySetting(
HarmCategory.sexuallyExplicit,
HarmBlockThreshold./* TODO(developer): OFF is not supported by the SDK yet. */,
),
SafetySetting(
HarmCategory.harassment,
HarmBlockThreshold./* TODO(developer): OFF is not supported by the SDK yet. */,
),
SafetySetting(
HarmCategory./* TODO(developer): HARM_CATEGORY_IMAGE_HATE is not supported by the SDK yet. */,
HarmBlockThreshold./* TODO(developer): OFF is not supported by the SDK yet. */,
),
SafetySetting(
HarmCategory./* TODO(developer): HARM_CATEGORY_IMAGE_DANGEROUS_CONTENT is not supported by the SDK yet. */,
HarmBlockThreshold./* TODO(developer): OFF is not supported by the SDK yet. */,
),
SafetySetting(
HarmCategory./* TODO(developer): HARM_CATEGORY_IMAGE_HARASSMENT is not supported by the SDK yet. */,
HarmBlockThreshold./* TODO(developer): OFF is not supported by the SDK yet. */,
),
SafetySetting(
HarmCategory./* TODO(developer): HARM_CATEGORY_IMAGE_SEXUALLY_EXPLICIT is not supported by the SDK yet. */,
HarmBlockThreshold./* TODO(developer): OFF is not supported by the SDK yet. */,
),
];
final ai =awaitFirebaseAI.vertexAI.instanceFor(location:'global');
final model = ai.generativeModel(
model:'gemini-2.0-flash-preview-image-generation',
generationConfig: generationConfig,
safetySettings: safetySettings,
);
// For multi-turn responses, start a chat session.final chat = model.startChat();
awaitsendMessage(
chat,
Content('user', [
TextPart('Text...'),
]),
);
}
Future<void> sendMessage(ChatSession chat, Content content) async {
final response =await chat.sendMessage(content);
print(response.text);
}
Google Cloud code reports that some HarmCategory's lack, that is the issue I'm facing.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using
firebase_ai
to generate images using Gemini, as in Firebase documentation.The same instructions are supplied in Google Cloud - Vertex AI - Create prompt - Get code - Flutter:
Google Cloud code reports that some HarmCategory's lack, that is the issue I'm facing.
My code:
Every call I do (with neutral texts) I get an error related to one of the lacking
HarmCategory
:Every help would be very appreciated, thanks.
Beta Was this translation helpful? Give feedback.
All reactions