retrieveChunks method

Future<List<ContentChunkModel>> retrieveChunks({
  1. required String mode,
  2. String? topicId,
  3. String? userMessage,
  4. String? domainId,
})

Retrieve the most relevant content chunks for a given mode.

For question-driven modes, uses userMessage to search for relevant chunks within topicId. For sequential modes, loads all chunks in order.

Implementation

Future<List<ContentChunkModel>> retrieveChunks({
  required String mode,
  String? topicId,
  String? userMessage,
  String? domainId,
}) async {
  if (topicId == null) return [];

  if (RetrievalConfig.questionDrivenModes.contains(mode) &&
      userMessage != null &&
      userMessage.isNotEmpty) {
    return _retrieveBySearch(
      topicId: topicId,
      userMessage: userMessage,
      domainId: domainId,
      mode: mode,
    );
  }

  // Sequential modes: document order (current behavior).
  return _supabase.getChunksForTopic(topicId);
}