addDocumentUtf8 method
Add a UTF-8 document payload while reducing input-side Dart String materialization.
Implementation
Future<SourceAddResult> addDocumentUtf8(
Uint8List bytes, {
String? metadata,
String? name,
ChunkingStrategy? strategy,
Duration? chunkDelay,
void Function(int done, int total)? onProgress,
String? collectionId,
}) async {
final normalized = _normalizeCollectionId(collectionId);
final service = await _serviceForCollection(normalized);
if (normalized == SourceRagService.defaultCollectionId) {
_startOperation();
}
try {
return await service.addSourceUtf8WithChunking(
bytes,
metadata: metadata,
name: name,
strategy: strategy,
chunkDelay: chunkDelay,
onProgress: onProgress,
);
} finally {
if (normalized == SourceRagService.defaultCollectionId) {
_endOperation();
}
}
}