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)
FirstBatch integrates Weaviate through the Weaviate
class.
First, we create a VectorStore
instance:
import weaviate, {ApiKey} from 'weaviate-ts-client';
import {Weaviate} from 'firstbatch';
// create a Weaviate client
const client = weaviate.client({
scheme: 'your-scheme',
host: 'your-host',
apiKey: new ApiKey('api-key'),
});
// instantiate the vector store
const vs = new Weaviate(client);
Then, we can use the Add a VectorDB method to register our client to the SDK:
await personalized.addVdb('my_db', vs);
The Weaviate vector store accepts optional arguments:
className
name of the Weaviate schemaoutputFields
fields to outputembeddingSize
vector embedding dimensionhistoryField
the name of the field for filtering that avoids previously retrieved datadistanceMetrics
the distance metric
Last updated