checkEmbeddingRequest function
void
checkEmbeddingRequest(})
Refuses, as an ArgumentError, contents with no part, or with images
or audio an engine of modalities was not loaded for.
Implementation
void checkEmbeddingRequest(
List<Content> contents, {
required Set<EmbedderModality> modalities,
required bool hasText,
required bool hasImages,
required bool hasAudio,
}) {
if (!hasText && !hasImages && !hasAudio) {
throw ArgumentError.value(contents, 'contents', 'has nothing to embed');
}
if (hasImages && !modalities.contains(EmbedderModality.image)) {
throw ArgumentError.value(
contents,
'contents',
'has images; load with visionBackend to embed them',
);
}
if (hasAudio && !modalities.contains(EmbedderModality.audio)) {
throw ArgumentError.value(
contents,
'contents',
'has audio; load with audioBackend to embed it',
);
}
}