addDocument method

Future<SourceAddResult> addDocument(
  1. String content, {
  2. String? metadata,
  3. String? filePath,
  4. ChunkingStrategy? strategy,
  5. void onProgress(
    1. int done,
    2. int total
    )?,
})

Add a document with automatic chunking and embedding.

The document is:

  1. Split into chunks based on file type (auto-detected from filePath)
  2. Each chunk is embedded using the loaded model
  3. Source and chunks are stored in the database

Remember to call rebuildIndex after adding documents for optimal search performance.

Implementation

Future<SourceAddResult> addDocument(
  String content, {
  String? metadata,
  String? filePath,
  ChunkingStrategy? strategy,
  void Function(int done, int total)? onProgress,
}) => _ragService.addSourceWithChunking(
  content,
  metadata: metadata,
  filePath: filePath,
  strategy: strategy,
  onProgress: onProgress,
);