process method

Future<AiProcessResponse> process(
  1. AiProcessInstructions instructions, {
  2. Map<String, AiFileUpload>? files,
})

Implementation

Future<AiProcessResponse> process(
  AiProcessInstructions instructions, {
  Map<String, AiFileUpload>? files,
}) async {
  _requireInitialized();

  final filePaths = <String, String>{};
  if (files != null) {
    for (final entry in files.entries) {
      filePaths[entry.key] = entry.value.path;
    }
  }
  if (!SmartLinksNativeApi.isEnabled) {
    throw UnsupportedError(
      'AI Gateway requires the SmartLinks native bridge (iOS/Android).',
    );
  }
  final result = await SmartLinksNativeApi.processAi(
    instructionsJson: jsonEncode(instructions.toJson()),
    files: filePaths,
  );
  return AiProcessResponse.fromJson(result ?? {'success': false});
}