Skip to content

Commit

Permalink
Fixing embedding function return call handling #48
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCsabaToth committed Oct 20, 2024
1 parent de4618f commit 4e5aaf8
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions lib/ai/service/embedding_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,36 @@ class Embeddings {
Embeddings.fromJson(Map<String, Object?> embeddingMap) {
textEmbeddings.clear();
if (embeddingMap.containsKey('text') && embeddingMap['text'] != null) {
final embeddingsList = embeddingMap['text']! as List<Object?>;
final embeddingsList = embeddingMap['text']! as List<dynamic>;
for (final embeddings in embeddingsList.nonNulls) {
final embedding = (embeddings as List<Object?>).nonNulls;
final embedding =
(embeddings as List<dynamic>).nonNulls.toList(growable: false);
if (embedding.isNotEmpty) {
textEmbeddings
.add(dimensionalityReduction(embedding as List<double>));
textEmbeddings.add(dimensionalityReduction(embedding.cast<double>()));
}
}
}

imageEmbeddings.clear();
if (embeddingMap.containsKey('image') && embeddingMap['image'] != null) {
final embedding = (embeddingMap['image']! as List<Object?>).nonNulls;
final embedding = (embeddingMap['image']! as List<dynamic>)
.nonNulls
.toList(growable: false);
if (embedding.isNotEmpty) {
imageEmbeddings
.addAll(dimensionalityReduction(embedding as List<double>));
.addAll(dimensionalityReduction(embedding.cast<double>()));
}
}

videoEmbeddings.clear();
if (embeddingMap.containsKey('video') && embeddingMap['video'] != null) {
final embeddingsList = embeddingMap['video']! as List<Object?>;
final embeddingsList = embeddingMap['video']! as List<dynamic>;
for (final embeddings in embeddingsList.nonNulls) {
final embedding = (embeddings as List<Object?>).nonNulls;
final embedding =
(embeddings as List<dynamic>).nonNulls.toList(growable: false);
if (embedding.isNotEmpty) {
videoEmbeddings
.add(dimensionalityReduction(embedding as List<double>));
.add(dimensionalityReduction(embedding.cast<double>()));
}
}
}
Expand Down

0 comments on commit 4e5aaf8

Please sign in to comment.