generate method

  1. @override
Future<List<String>> generate({
  1. required String prompt,
  2. Uint8List? image,
  3. double temperature = 0.2,
  4. int seed = 0,
  5. int topK = 3,
  6. int candidateCount = 1,
  7. int maxOutputTokens = 256,
})
override

Generates a list of strings based on a prompt and optional image using the on-device model.

Implementation

@override
Future<List<String>> generate({
  required String prompt,
  Uint8List? image,
  double temperature = 0.2,
  int seed = 0,
  int topK = 3,
  int candidateCount = 1,
  int maxOutputTokens = 256,
}) async {
  final List<String>? result = await methodChannel
      .invokeListMethod<String>('generateText', {
        'prompt': prompt,
        'image': image,
        'temperature': temperature,
        'seed': seed,
        'topK': topK,
        'candidateCount': candidateCount,
        'maxOutputTokens': maxOutputTokens,
      });
  if (result == null) {
    throw PlatformException(
      code: 'NULL_RESPONSE',
      message: 'The model returned null.',
    );
  }
  return result;
}