class Ollama::Documents

def find_where(string, text_size: nil, text_count: nil, **opts)

def find_where(string, text_size: nil, text_count: nil, **opts)
  if text_count
    opts[:max_records] =  text_count
  end
  records = find(string, **opts)
  size, count = 0, 0
  records.take_while do |record|
    if text_size and (size += record.text.size) > text_size
      next false
    end
    if text_count and (count += 1) > text_count
      next false
    end
    true
  end
end