Skip to content

Commit

Permalink
Generate embeddings before clearing
Browse files Browse the repository at this point in the history
  • Loading branch information
collindutter committed Sep 9, 2024
1 parent 1e5974c commit 37a41ba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions griptape/artifacts/text_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 37a41ba

Please sign in to comment.