Skip to content

Commit

Permalink
fix naming
Browse files Browse the repository at this point in the history
  • Loading branch information
lferran committed Jul 24, 2024
1 parent 739c680 commit e0aeb9f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions nucliadb/src/nucliadb/ingest/orm/knowledgebox.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@


@dataclass
class ExternalIndex:
class VectorsetExternalIndex:
vectorset_id: str
dimension: int

Expand Down Expand Up @@ -178,7 +178,7 @@ async def create(
kbid,
request=external_index_provider,
indexes=[
ExternalIndex(
VectorsetExternalIndex(
vectorset_id="default", dimension=semantic_model.vector_dimension
)
],
Expand All @@ -187,16 +187,16 @@ async def create(
partial(cls._maybe_delete_external_indexes, kbid, stored_external_index_provider)
)
else:
external_indexes = []
vs_external_indexes = []
for vectorset_id, semantic_model in semantic_models.items(): # type: ignore
# if this KB uses a matryoshka model, we can choose a different
# dimension
if len(semantic_model.matryoshka_dimensions) > 0:
dimension = choose_matryoshka_dimension(semantic_model.matryoshka_dimensions)
else:
dimension = semantic_model.vector_dimension
external_indexes.append(
ExternalIndex(vectorset_id=vectorset_id, dimension=dimension)
vs_external_indexes.append(
VectorsetExternalIndex(vectorset_id=vectorset_id, dimension=dimension)
)
vectorset_config = knowledgebox_pb2.VectorSetConfig(
vectorset_id=vectorset_id,
Expand All @@ -212,14 +212,14 @@ async def create(
await datamanagers.vectorsets.set(txn, kbid=kbid, config=vectorset_config)

stored_external_index_provider = await cls._maybe_create_external_indexes(
kbid, request=external_index_provider, indexes=external_indexes
kbid, request=external_index_provider, indexes=vs_external_indexes
)
rollback_ops.append(
partial(
cls._maybe_delete_external_indexes,
kbid,
stored_external_index_provider,
external_indexes,
vs_external_indexes,
)
)

Expand Down Expand Up @@ -526,10 +526,11 @@ async def _maybe_create_external_indexes(
cls,
kbid: str,
request: CreateExternalIndexProviderMetadata,
indexes: list[ExternalIndex],
indexes: list[VectorsetExternalIndex],
) -> StoredExternalIndexProviderMetadata:
metadata = StoredExternalIndexProviderMetadata(type=request.type)
if request.type != ExternalIndexProviderType.PINECONE:
# Only pinecone is supported for now
return metadata

api_key = request.pinecone_config.api_key
Expand Down Expand Up @@ -559,9 +560,10 @@ async def _maybe_delete_external_indexes(
cls,
kbid: str,
external_index_provider: StoredExternalIndexProviderMetadata,
created_external_indexes: Optional[list[ExternalIndex]] = None,
created_external_indexes: Optional[list[VectorsetExternalIndex]] = None,
):
if external_index_provider.type != ExternalIndexProviderType.PINECONE:
# Only pinecone is supported for now
return

encrypted_api_key = external_index_provider.pinecone_config.encrypted_api_key
Expand Down

0 comments on commit e0aeb9f

Please sign in to comment.