Skip to content

Commit

Permalink
allow remove
Browse files Browse the repository at this point in the history
  • Loading branch information
JosuaKrause committed Aug 6, 2024
1 parent 1c19623 commit 7aea4c5
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions app/system/smind/vec.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ def add_embed(
chunk_hash = compute_chunk_hash(chunks)
doc_embed = compute_doc_embedding(embed_size, chunks)
cur_hash, new_count = chunk_hash
is_remove = new_count == 0
main_id = get_main_id(data)
main_uuid = get_main_uuid(data)

Expand Down Expand Up @@ -663,15 +664,18 @@ def add_embed(

base = data["base"]
doc_type = meta_obj["doc_type"]
required_doc_types = KNOWN_DOC_TYPES.get(base)
if required_doc_types is not None and doc_type not in required_doc_types:
raise ValueError(
f"base {base} requires doc_type from "
f"{required_doc_types} not {doc_type}")
required_base = DOC_TYPE_TO_BASE.get(doc_type)
if required_base is not None and required_base != base:
raise ValueError(
f"doc_type {doc_type} requires base {required_base} != {base}")
if not is_remove:
required_doc_types = KNOWN_DOC_TYPES.get(base)
if (
required_doc_types is not None
and doc_type not in required_doc_types):
raise ValueError(
f"base {base} requires doc_type from "
f"{required_doc_types} not {doc_type}")
required_base = DOC_TYPE_TO_BASE.get(doc_type)
if required_base is not None and required_base != base:
raise ValueError(
f"doc_type {doc_type} requires base {required_base} != {base}")

vec_name = get_db_name(name, is_vec=True)

Expand Down Expand Up @@ -724,7 +728,7 @@ def convert_chunk(
if chunks:
insert_chunks()

if new_count != 0:
if not is_remove:
new_index_count = build_scalar_index(
db,
name,
Expand Down

0 comments on commit 7aea4c5

Please sign in to comment.