gemini_ai 0.0.2 gemini_ai: ^0.0.2 copied to clipboard
Plugin for Google Gemini AI Library. You can add artificial intelligence capability to your Flutter application using the Gemini AI library.
Gemini API Flutter Plugin #
Flutter plugin of Gemini AI for Flutter Developers that uses native Android and iOS libraries.
My personal website: cihanurtekin.com
Usage #
To experience Gemini online: Google Maker Suite
Generative Model #
import 'package:gemini_ai/model/generative_model.dart';
GenerativeModel generativeModel = GenerativeModel(
modelName: "gemini-pro",
apiKey: "YOUR_API_KEY_HERE",
generationConfig: _generationConfig,
safetySettings: _safetySettings,
);
modelName: String
apiKey: String
generationConfig: GenerationConfig?
safetySettings: List<SafetySetting>
Generation Config #
import 'package:gemini_ai/model/generation_config.dart';
GenerationConfig _generationConfig = GenerationConfig(
temperature: 0.9,
topK: 1,
topP: 1,
maxOutputTokens: 2048,
);
temperature: double?
topK: int?
topP: double?
candidateCount: int?
maxOutputTokens: int?
stopSequences: List<String>?
Safety Settings #
import 'package:gemini_ai/model/safety_setting.dart';
import 'package:gemini_ai/enum/block_threshold.dart';
import 'package:gemini_ai/enum/harm_category.dart';
List<SafetySetting> _safetySettings = [
SafetySetting(
HarmCategory.harassment,
BlockThreshold.mediumAndAbove,
),
SafetySetting(
HarmCategory.hateSpeech,
BlockThreshold.mediumAndAbove,
),
SafetySetting(
HarmCategory.sexuallyExplicit,
BlockThreshold.mediumAndAbove,
),
SafetySetting(
HarmCategory.dangerousContent,
BlockThreshold.mediumAndAbove,
),
];
HarmCategory: enum (unknown, harassment, hateSpeech, dangerousContent)
BlockThreshold: enum (unspecified, lowAndAbove, mediumAndAbove, onlyHigh, none)
Generate content #
Get response from Gemini AI with only one line of code using the generateContent
method. For a full example, you can visit the example tab.
import 'package:gemini_ai/gemini_ai.dart';
GeminiAi _gemini = GeminiAi();
String? content = await _gemini.generateContent(
GeminiConfig.generativeModel,
"Your message to Gemini",
);
License #
Gemini AI Flutter Plugin is licensed under the BSD-3-Clause License.
My personal website: cihanurtekin.com