ActiveEmbedderParams constructor
ActiveEmbedderParams({
- required String modelPath,
- String? tokenizerPath,
- PreferredBackend? preferredBackend,
The requested backend is normalised HERE rather than in a method a caller has to remember, so activeBackend always means "the backend this embedder was built for" and there is no way to compare un-normalised values by accident.
modelPath is checked with a throw, not an assert. An assert is stripped
in release, and the release failure is not a crash: an empty path makes
every embedder compare equal to every other, so the cache hands back a
stale model's vectors — the exact silent-wrong-data failure this type was
created to prevent. RuntimeConfig.modelPath in this same file documents
'' as the ordinary value on web, so an adopter wiring it straight in is
the reachable route.
Implementation
ActiveEmbedderParams({
required this.modelPath,
this.tokenizerPath,
PreferredBackend? preferredBackend,
}) : activeBackend = _resolvedBackend(preferredBackend) {
if (modelPath.isEmpty) {
throw ArgumentError.value(
modelPath,
'modelPath',
'identifies the embedder, so it cannot be empty',
);
}
}