createEmbeddingEngineWith function

Future<EmbeddingEngine> createEmbeddingEngineWith(
  1. LiteRtLmEmbeddingConfig config, {
  2. LiteRtLmEmbeddingBindings openBindings()?,
  3. Allocator allocator = calloc,
  4. DateTime clock()?,
})

An EmbeddingEngine over the embedder config config, already placed: for a caller that decides the placement itself, on another isolate (the Flutter adapter places on the app's isolate, where the platform channel that prepares an Android NPU dispatch directory is, and loads on a worker). openBindings, allocator and clock are for tests.

Implementation

Future<EmbeddingEngine> createEmbeddingEngineWith(
  LiteRtLmEmbeddingConfig config, {
  LiteRtLmEmbeddingBindings Function()? openBindings,
  Allocator allocator = calloc,
  DateTime Function()? clock,
}) async {
  final embedder = LiteRtLmEmbedder(
    config,
    openBindings: openBindings,
    allocator: allocator,
    clock: clock,
  );
  return EmbeddingEngine._(embedder, await embedder.load());
}