Skip to content

Commit

Permalink
Add parameters to sqlvector and build nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
blythed committed Jun 23, 2024
1 parent 0eb74c2 commit 396580b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ build_sandbox: ## Build superduperdb/sandbox:<commit> image (RUNNER=<cpu|cuda>)
build_nightly: ## Build superduperdb/nightly:<commit> image (EXTRA_REQUIREMENTS_FILE=<path>) (RUNNER=<cpu|cuda>)
docker build . -f ./deploy/images/superduperdb/Dockerfile \
--build-arg BUILD_ENV="nightly" \
--platform linux/amd64 \
--progress=plain \
$(if $(EXTRA_REQUIREMENTS_FILE),--build-arg EXTRA_REQUIREMENTS_FILE=$(EXTRA_REQUIREMENTS_FILE),) \
$(if $(RUNNER),--build-arg RUNNER=$(RUNNER),) \
Expand Down
5 changes: 4 additions & 1 deletion superduperdb/components/vector_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,19 @@ def vector(shape, identifier: t.Optional[str] = None):
)


def sqlvector(shape):
@component()
def sqlvector(shape, bytes_encoding: str = 'Bytes'):
"""Create an encoder for a vector (list of ints/ floats) of a given shape.
This is used for compatibility with SQL databases, as the default vector
:param shape: The shape of the vector
:param bytes_encoding: The encoding of the bytes
"""
return DataType(
identifier=f'sqlvector[{str_shape(shape)}]',
shape=shape,
encoder=EncodeArray(dtype='float64'),
decoder=DecodeArray(dtype='float64'),
bytes_encoding=bytes_encoding,
)
5 changes: 4 additions & 1 deletion superduperdb/ext/openai/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
)
from openai._types import NOT_GIVEN

from superduperdb import CFG
from superduperdb.backends.ibis.data_backend import IbisDataBackend
from superduperdb.backends.ibis.field_types import dtype
from superduperdb.backends.query_dataset import QueryDataset
Expand Down Expand Up @@ -128,7 +129,9 @@ def pre_create(self, db):
super().pre_create(db)
if isinstance(db.databackend.type, IbisDataBackend):
if self.datatype is None:
self.datatype = sqlvector(self.shape)
self.datatype = sqlvector(
shape=self.shape, bytes_encoding=CFG.bytes_encoding
)
elif self.datatype is None:
self.datatype = vector(shape=self.shape)

Expand Down

0 comments on commit 396580b

Please sign in to comment.