From 4ac583a1133c2473b1dd0617b38bff6ba1c7af5e Mon Sep 17 00:00:00 2001 From: Collin Dutter Date: Mon, 9 Sep 2024 12:24:50 -0700 Subject: [PATCH] Generate embeddings before clearing --- griptape/artifacts/text_artifact.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/griptape/artifacts/text_artifact.py b/griptape/artifacts/text_artifact.py index 7a3b62e3b8..da8a7cd9aa 100644 --- a/griptape/artifacts/text_artifact.py +++ b/griptape/artifacts/text_artifact.py @@ -31,11 +31,12 @@ def to_bytes(self) -> bytes: return str(self.value).encode(encoding=self.encoding, errors=self.encoding_error_handler) def generate_embedding(self, driver: BaseEmbeddingDriver) -> list[float]: + embedding = driver.embed_string(str(self.value)) + if self.embedding is None: self.embedding = [] - self.embedding.clear() - self.embedding.extend(driver.embed_string(str(self.value))) + self.embedding.extend(embedding) return self.embedding