Weaviate

FirstBatch integrates Weaviate through the Weaviate Class.

Example run:

from firstbatch import Weaviate
import weaviate

auth_config = weaviate.AuthApiKey(api_key=os.environ["WEAVIATE_API_KEY"])
client = weaviate.Client(
    url=os.environ["WEAVIATE_URL"],
    auth_client_secret=auth_config,
)
index_name = "default"
embedding_size = int(os.environ["EMBEDDING_SIZE"])
config = Config(batch_size=20, verbose=True)
personalized = FirstBatch(api_key=os.environ["FIRSTBATCH_API_KEY"], config=config)
personalized.add_vdb("weaviate_db", Weaviate(client=client, index_name=index_name, embedding_size=embedding_size))

Distance metric can explicitly be provided. If not, default value is COSINE_SIM

class DistanceMetric(Enum):
    COSINE_SIM = "cosine_sim"
    EUCLIDEAN_DIST = "euclidean_dist"
    DOT_PRODUCT = "dot_product"
from firstbatch import DistanceMetric

Weaviate(client=client, index_name=index_name,
distance_metric=DistanceMetric.EUCLIDEAN_DIST)

Last updated