FirstBatch SDK
  • Get Started
    • Introduction
    • Installation
    • Quick Start
  • Learn
    • Key Concepts
      • Embeddings
      • Vector Databases
      • User Embeddings
    • Sessions
    • Signals
    • Batches
    • Algorithms
      • Batch Types
        • Random
        • Sampled
        • Personalized
        • Biased
      • Parameters & Tuning
    • Cookbook
      • Simple Flask App
      • Personalized RSS Feed
      • Personalized Mini TikTok
      • User-Intent AI Agents
      • Extending RAG: User Embeddings
      • Prompt Based User Journeys
      • User-Centric Promoted Content
  • Modules
    • FirstBatch
    • Algorithms
    • VectorStores
      • Pinecone
      • Weaviate
      • Qdrant
      • Typesense
      • Supabase
      • Chroma
Powered by GitBook
On this page
  1. Modules
  2. VectorStores

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 namespace

  • embeddingSize vector embedding dimension

  • historyField the name of the field for filtering that avoids previously retrieved data

  • distanceMetrics the distance metric

PreviousVectorStoresNextWeaviate

Last updated 1 year ago

Then, we can use the method to register our client to the SDK:

Add a VectorDB