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)
FirstBatch integrates Pinecone through the Pinecone
class.
First, we create a VectorStore
instance:
import {Pinecone as PineconeClient} from '@pinecone-database/pinecone';
import {Pinecone} from 'firstbatch';
// create a Pinecone client & index
const pinecone = new PineconeClient({
apiKey: 'your-api-key',
environment: 'your-env',
});
// instantiate the vector store
const index = pinecone.index('your-index');
const vs = new Pinecone(index);
await personalized.addVdb('my_db', vs);
The Pinecone vector store accepts the following optional arguments:
namespace
the Pinecone namespaceembeddingSize
vector embedding dimensionhistoryField
the name of the field for filtering that avoids previously retrieved datadistanceMetrics
the distance metric
Last updated