Skip to content

Release v3.0.0

Latest
Compare
Choose a tag to compare
@austin-denoble austin-denoble released this 06 Feb 23:12

This version of the Pinecone Go SDK depends on version 2025-01 of the Pinecone API. You can read more about versioning here. This v3 SDK release line should continue to receive fixes as long as the 2025-01 API version is in support.

Features

Sparse index support

You can now work with sparse-only indexes. These indexes enable direct indexing and retrieval of sparse vectors, supporting traditional methods like BM25 and learned sparse models such as pinecone-sparse-english-v0. You can read more about getting started with sparse-only indexes here.

The following example demonstrates creating a new sparse-only index, and upserting some arbitrary sparse vector data:

package main

import (
	"context"
	"fmt"
	"github.com/pinecone-io/go-pinecone/v3/pinecone"
	"log"
	"os"
)

func main() {
	ctx := context.Background()

	clientParams := pinecone.NewClientParams{
		ApiKey: os.Getenv("PINECONE_API_KEY"),
	}

	pc, err := pinecone.NewClient(clientParams)
	if err != nil {
		log.Fatalf("Failed to create Client: %v", err)
	} else {
		fmt.Println("Successfully created a new Client object!")
	}

	indexName := "my-serverless-index"
	vectorType := "sparse"
	metric := pinecone.Dotproduct

	idx, err := pc.CreateServerlessIndex(ctx, &pinecone.CreateServerlessIndexRequest{
		Name:       indexName,
		Cloud:      pinecone.Aws,
		Region:     "us-east-1",
		Metric:     &metric,
		VectorType: &vectorType,
		Tags:       &pinecone.IndexTags{"environment": "development"},
	})
	if err != nil {
		log.Fatalf("Failed to create serverless index: %v", err)
	}

	sparseValuesA := pinecone.SparseValues{
		Indices: []uint32{0, 1, 2, 3, 4, 5, 6, 7},
		Values:  []float32{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0},
	}
	sparseValuesB := pinecone.SparseValues{
		Indices: []uint32{0, 1, 2, 3, 4, 5, 6, 7},
		Values:  []float32{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0},
	}
	sparseValuesC := pinecone.SparseValues{
		Indices: []uint32{0, 1, 2, 3, 4, 5, 6, 7},
		Values:  []float32{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0},
	}

	sparseVectors := []*pinecone.Vector{
		{
			Id:           "A",
			Metadata:     metadata,
			SparseValues: &sparseValuesA,
		},
		{
			Id:           "B",
			Metadata:     metadata,
			SparseValues: &sparseValuesB,
		},
		{
			Id:           "C",
			Metadata:     metadata,
			SparseValues: &sparseValuesC,
		},
	}
}

Breaking Changes

  • EmbedParameters is no longer typed as a pointer.
  • CreateServerlessIndexRequest and CreatePodIndexRequest structs have been updated, and fields are now classified as pointers to better denote optionality around creating specific types of indexes: Metric, Dimension, VectorType, and DeletionProtection.
  • Values in the Vector type are now a pointer to allow flexibility when working with sparse-only indexes.

What's Changed

Full Changelog: v2.2.0...v3.0.0