Gemini class
Gemini
Flutter Google Gemini SDK. Google Gemini is a set of cutting-edge large language models
(LLMs) designed to be the driving force behind Google's future AI initiatives.
implements GeminiInterface
and GeminiInterface
defines all methods of Gemini
Constructors
-
Gemini.init({required String apiKey, String? baseURL, Map<
String, dynamic> ? headers, List<SafetySetting> ? safetySettings, GenerationConfig? generationConfig, bool? enableDebugging, String? version}) -
singleton initialize Gemini.init
factory
-
Gemini.reInitialize({required String apiKey, String? baseURL, Map<
String, dynamic> ? headers, List<SafetySetting> ? safetySettings, GenerationConfig? generationConfig, bool? enableDebugging, String? version}) -
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- typeProvider ↔ GeminiResponseProvider?
-
getter/setter pair
Methods
-
batchEmbedContents(
List< String> texts, {String? modelName, List<SafetySetting> ? safetySettings, GenerationConfig? generationConfig}) → Future<List< List< ?>num> ?> -
Embedding
is a technique used to represent information as a list of floating point numbers in an array. With Gemini, you can represent text (words, sentences, and blocks of text) in a vectorized form, making it easier to compare and contrast embeddings. For example, two texts that share a similar subject matter or sentiment should have similar embeddings, which can be identified through mathematical comparison techniques such as cosine similarity. -
cancelRequest(
) → Future< void> -
chat(
List< Content> chats, {String? modelName, List<SafetySetting> ? safetySettings, GenerationConfig? generationConfig, String? systemPrompt}) → Future<Candidates?> -
chat or
Multi-turn conversations
Using Gemini, you can build freeform conversations across multiple turns. -
countTokens(
String text, {String? modelName, List< SafetySetting> ? safetySettings, GenerationConfig? generationConfig}) → Future<int?> - countTokens When using long prompts, it might be useful to count tokens before sending any content to the model.
-
embedContent(
String text, {String? modelName, List< SafetySetting> ? safetySettings, GenerationConfig? generationConfig}) → Future<List< num> ?> - embedContent description in upper comments
-
info(
{required String model}) → Future< GeminiModel> -
info
If you
GET
a model's URL, the API used theget
method to return information about that model such as version, display name, input token limit, etc. -
listModels(
) → Future< List< GeminiModel> > -
listModels
If you
GET
themodels
directory, it used thelist
method to list all of the models available through the API, including both the Gemini and PaLM family models. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
streamChat(
List< Content> chats, {String? modelName, List<SafetySetting> ? safetySettings, GenerationConfig? generationConfig}) → Stream<Candidates> -
streamGenerateContent(
String text, {List< Uint8List> ? images, String? modelName, List<SafetySetting> ? safetySettings, GenerationConfig? generationConfig}) → Stream<Candidates> - streamGenerateContent By default, the model returns a response after completing the entire generation process. You can achieve faster interactions by not waiting for the entire result, and instead use streaming to handle partial results.
-
text(
String text, {String? modelName, List< SafetySetting> ? safetySettings, GenerationConfig? generationConfig}) → Future<Candidates?> -
text
Use thegenerateContent
method to generate a response from the model given an input message. If the input contains only text, use thegemini-pro
model. -
textAndImage(
{required String text, required List< Uint8List> images, String? modelName, List<SafetySetting> ? safetySettings, GenerationConfig? generationConfig}) → Future<Candidates?> -
textAndImage If the input contains both text and image, use
the
gemini-pro-vision
model. The following snippets help you build a request and send it to the REST API. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- enableDebugging ↔ bool?
-
enableDebugging
to see request progress
getter/setter pair
- instance ↔ Gemini
-
singleton instance from main Gemini class
getter/setter pair