From 3143308136ec4e71c8a5f9a127119e475329c1a2 Mon Sep 17 00:00:00 2001 From: Timon Vonk Date: Wed, 26 Jun 2024 21:28:49 +0200 Subject: [PATCH] fix(embed): panic if number of embeddings and node are equal --- swiftide/src/transformers/embed.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/swiftide/src/transformers/embed.rs b/swiftide/src/transformers/embed.rs index 321d4c42..1606c8b2 100644 --- a/swiftide/src/transformers/embed.rs +++ b/swiftide/src/transformers/embed.rs @@ -6,6 +6,7 @@ use crate::{ }; use anyhow::Result; use async_trait::async_trait; +use itertools::Itertools as _; /// A transformer that can generate embeddings for an `IngestionNode` /// @@ -72,14 +73,14 @@ impl BatchableTransformer for Embed { .map(|embeddings| { nodes .into_iter() - .zip(embeddings) + // Will panic if the number of embeddings doesn't match the number of nodes + .zip_eq(embeddings) .map(|(mut n, v)| { n.vector = Some(v); - Ok(n) + n }) - .collect::>>() + .collect::>() }) - .unwrap_or_else(|e| vec![Err(e)]) .into() }