generate method

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

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

Implementation

@override
Future<List<String>> generate({
  required String prompt,
  double? temperature,
  int? seed,
  int? topK,
  int? candidateCount,
  int? maxOutputTokens,
}) async {
  final List<String>? result =
      await methodChannel.invokeListMethod<String>('generateText', {
    'prompt': prompt,
    '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;
}