Protect null embeddings - v2.0 (#627)

* Don't emit graph embeddings if there aren't any.

* Don't store graph embeddings in a knowledge store if there's an empty list.

* Translate between Cassandra's 'null' representing an empty list and an
  empty list which is what the surrounding code wants (and stored in the
  first place).

* Avoid emitting empty embedding lists

* Avoid output empty triple lists

* Fix tests
This commit is contained in:
cybermaggedon 2026-02-09 14:57:36 +00:00 committed by GitHub
parent 98827e5561
commit 8574861196
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 88 additions and 91 deletions

View file

@ -435,14 +435,17 @@ class KnowledgeTableStore:
else:
metadata = []
triples = [
Triple(
s = tuple_to_term(elt[0], elt[1]),
p = tuple_to_term(elt[2], elt[3]),
o = tuple_to_term(elt[4], elt[5]),
)
for elt in row[3]
]
if row[3]:
triples = [
Triple(
s = tuple_to_term(elt[0], elt[1]),
p = tuple_to_term(elt[2], elt[3]),
o = tuple_to_term(elt[4], elt[5]),
)
for elt in row[3]
]
else:
triples = []
await receiver(
Triples(
@ -491,13 +494,16 @@ class KnowledgeTableStore:
else:
metadata = []
entities = [
EntityEmbeddings(
entity = tuple_to_term(ent[0][0], ent[0][1]),
vectors = ent[1]
)
for ent in row[3]
]
if row[3]:
entities = [
EntityEmbeddings(
entity = tuple_to_term(ent[0][0], ent[0][1]),
vectors = ent[1]
)
for ent in row[3]
]
else:
entities = []
await receiver(
GraphEmbeddings(