initialize method
Future<Map<String, dynamic> >
initialize({
- required String modelName,
- required double temperature,
- required int topK,
- required double topP,
- required int maxOutputTokens,
override
Implementation
@override
Future<Map<String, dynamic>> initialize({
required String modelName,
required double temperature,
required int topK,
required double topP,
required int maxOutputTokens,
}) async {
try {
final result = await methodChannel.invokeMethod<Map<dynamic, dynamic>>(
'initialize',
{
'modelName': modelName,
'temperature': temperature,
'topK': topK,
'topP': topP,
'maxOutputTokens': maxOutputTokens,
},
);
return Map<String, dynamic>.from(result ?? {});
} on PlatformException catch (e) {
if (e.code == 'UNSUPPORTED_DEVICE') {
throw UnsupportedDeviceException(
e.message ?? 'Device not supported for Gemini Nano',
code: e.code,
details: e.details,
);
} else if (e.code == 'AICORE_UNAVAILABLE') {
throw AiCoreUnavailableException(
e.message ?? 'AICore not available',
code: e.code,
details: e.details,
);
}
throw InitializationException(
e.message ?? 'Failed to initialize model',
code: e.code,
details: e.details,
);
}
}