Pinecone

FirstBatch integrates Pinecone through the Pinecone Class.

Example run:

from firstbatch import Pinecone
import pinecone

api_key = os.environ["PINECONE_API_KEY"]
env =  os.environ["PINECONE_ENV"]
index_name = "default"
dim = 1536
pinecone.init(api_key=api_key, environment=env)
pinecone.describe_index(index_name)
index = pinecone.Index(index_name)
config = Config(batch_size=20, verbose=True)
personalized = FirstBatch(api_key=os.environ["FIRSTBATCH_API_KEY"], config=config)
personalized.add_vdb("pinecone_db", Pinecone(index))

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

Pinecone(index, distance_metric=DistanceMetric.EUCLIDEAN_DIST)

Last updated