Skip to content

Releases: pinecone-io/pinecone-ts-client

4.1.0

09 Jan 17:42
Compare
Choose a tag to compare

Features

Index tags

Users can now tag indexes with key:value pairs for categorizing and identifying indexes. You can add tags when creating an index, or modify/delete tags when configuring an index.

Example code:

import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
await pc.createIndex({
  name: 'sample-index',
  dimension: 1536,
  spec: {
    serverless: {
      cloud: 'aws',
      region: 'us-west-2',
    },
  },
  tags: { team: 'data-science' },  // Index tag here
});

Retries

The upsert, configureIndex, and update operations now make use of a new RetryOnServerFailure class. This class takes in an asynchronous operation and retries it if the server respond with either of 2 new errors: a PineconeUnavailableError (503) or a PineconeInternalServerError (500). The RetryOnServerFailure class retries 3 times as a default with an exponential backoff and a jitter factor. If maxRetries exceeds 10, an error is thrown to avoid overloading the server.

Housekeeping

  • Add integration testing w/external NextJS app (Edge runtime) by @aulorbe in #304
  • Rename previously-named e2e workflow to external-app for consistency by @aulorbe in #311
  • Remove extra call to delete an already-deleted index in bulkImport integration test by @aulorbe in #313
  • Refactor listPaginated tests by @aulorbe in #312
  • Remove git submodule cmds and update Vercel cmds in external-app tests by @aulorbe in #316
  • Small fix in deleteAll documentation regarding namespaces by @kehanzhang in #314
  • Add sleep to codegen script by @aulorbe in #321

New Contributors

Full Changelog: v4.0.0...4.1.0

v4.0.0

23 Oct 21:33
Compare
Choose a tag to compare

Features

This version of the Typescript client introduces two new endpoints: Rerank and Import.

Rerank

Rerank provides users the ability to rerank documents in descending relevance-order against a given query. Reranking documents is a common "second-pass" ranking strategy broadly used in retrieval applications.

Example code:

import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();
const rerankingModel = 'bge-reranker-v2-m3';
const myQuery = 'What are some good Turkey dishes for Thanksgiving?';

// Option 1: Documents as an array of strings
const myDocsStrings = [
  'I love turkey sandwiches with pastrami',
  'A lemon brined Turkey with apple sausage stuffing is a classic Thanksgiving main',
  'My favorite Thanksgiving dish is pumpkin pie',
  'Turkey is a great source of protein',
];

// Option 1 response
const response = await pc.inference.rerank(
  rerankingModel,
  myQuery,
  myDocsStrings
);
console.log(response);
// {
// model: 'bge-reranker-v2-m3',
// data: [
//   { index: 1, score: 0.5633179, document: [Object] },
//   { index: 2, score: 0.02013874, document: [Object] },
//   { index: 3, score: 0.00035419367, document: [Object] },
//   { index: 0, score: 0.00021485926, document: [Object] }
// ],
// usage: { rerankUnits: 1 }
// }

// Option 2: Documents as an array of objects
const myDocsObjs = [
  {
    title: 'Turkey Sandwiches',
    body: 'I love turkey sandwiches with pastrami',
  },
  {
    title: 'Lemon Turkey',
    body: 'A lemon brined Turkey with apple sausage stuffing is a classic Thanksgiving main',
  },
  {
    title: 'Thanksgiving',
    body: 'My favorite Thanksgiving dish is pumpkin pie',
  },
  {
    title: 'Protein Sources',
    body: 'Turkey is a great source of protein',
  },
];

// Option 2: Options object declaring which custom key to rerank on
// Note: If no custom key is passed via `rankFields`, each doc must contain a `text` key, and that will act as the default)
const rerankOptions = {
  topN: 3,
  returnDocuments: false,
  rankFields: ['body'],
  parameters: {
    inputType: 'passage',
    truncate: 'END',
  },
};

// Option 2 response
const response = await pc.inference.rerank(
  rerankingModel,
  myQuery,
  myDocsObjs,
  rerankOptions
);
console.log(response);
// {
// model: 'bge-reranker-v2-m3',
// data: [
//   { index: 1, score: 0.5633179, document: undefined },
//   { index: 2, score: 0.02013874, document: undefined },
//   { index: 3, score: 0.00035419367, document: undefined },
// ],
// usage: { rerankUnits: 1 }
//}

Import

Import is a long-running, asynchronous operation that gives users the ability to import vectors directly from object storage (e.g. S3) into a Pinecone index. It is intended to be used with large-scale jobs. For small-scale jobs (e.g. <1000 vectors), we recommend continuing to use upsert.

Example code:

import { Pinecone } from '@pinecone-database/pinecone';

const pc = new Pinecone();
const indexName = 'sample-index';

await pc.createIndex({
  name: indexName,
  dimension: 10,
  spec: {
    serverless: {
      cloud: 'aws',
      region: 'eu-west-1',
    },
  },
});

const index = pc.Index(indexName);

const storageURI = 's3://my-bucket/my-directory/';

await index.startImport(storageURI, 'continue'); // "Continue" will avoid aborting the operation if errors are encountered.

// {
//   "id": "import-id"
// }

Housekeeping

  • Added a section to the README outlining how to use the Typescript client with a proxy server
  • Re-architected test suite to be more efficient (primarily: centralization and sharing of test indexes)

Full Changelog: 3.0.3...v4.0.0

v3.0.3

11 Sep 18:18
399803e
Compare
Choose a tag to compare

Fixes

  • Remove extra logging from getFetch() s/o @maxmetcalfe in #280
  • Some general fixes/internal enhancements to CI workflows

New Contributors

Full Changelog: 3.0.2...v3.0.3

3.0.2

26 Aug 23:44
Compare
Choose a tag to compare

Fixes

Remove util:node function

This patch removes a native Node utility function that was causing issues for users running in Edge. There are no downstream affects of its removal; code should run as it previously was without interruptions or changes.

New Contributors

Full Changelog: v3.0.1...3.0.2

v3.0.1

20 Aug 22:56
Compare
Choose a tag to compare

Fixes

Compatibility with Edge runtimes

This patch removes the @sinclair/typebox and ajv libraries, which caused compatibility issues for users running in Edge runtimes (Cloudflare, Vercel, etc.).

Removal of crossFetch ponyfill

Since this Typescript client no longer supports versions of Node <18, we can remove the crossFetch ponyfill from src/utils/fetch.ts, as it was only necessary as a failsafe for users running older versions of Node.

New Contributors

Full Changelog: v3.0.0...v3.0.1

Release v3.0.0

19 Jul 19:23
Compare
Choose a tag to compare

Features

API versioning

This updated release of the Pinecone TypeScript SDK depends on API version 2024-07. This v3 SDK release line should continue to receive fixes as long as the 2024-07 API version is in support.

Inference API

Try out Pinecone's new Inference API, currently in public preview.

import { Pinecone } from '@pinecone-database/pinecone';

const client = new Pinecone({ apiKey: 'YOUR_API_KEY' });
const model = 'multilingual-e5-large';

const text = [
  'Turkey is a classic meat to eat at American Thanksgiving.',
  'Many people enjoy the beautiful mosques in Turkey.',
];

async function generateDocEmbeddings() {
  try {
    return await client.inference.embed(
      model,
      input: text,
      params: { inputType: 'passage', truncate: 'END' }
    );
  } catch (error) {
    console.error('Error generating embeddings:', error);
  }
}

Deletion Protection

Use deletion protection to prevent your most important indexes from accidentally being deleted. This feature is available for both serverless and pod indexes.

To enable this feature for existing indexes, use configureIndex.

import { Pinecone } from '@pinecone-database/pinecone';

const client = new Pinecone({ apiKey: 'YOUR_API_KEY' });

// Enable deletion protection
await client.configureIndex('example-index', { deletionProtection: 'enabled' });

When deletion protection is enabled, calls to deleteIndex will fail until you first disable the deletion protection.

// To disable deletion protection
await client.configureIndex('example-index', { deletionProtection: 'disabled' });

If you want to enable this feature at the time of index creation, createIndex now accepts an optional keyword argument. The feature is disabled by default.

import { Pinecone } from '@pinecone-database/pinecone';

const client = new Pinecone({ apiKey: 'YOUR_API_KEY' });
await client.createIndex({ 
  name: 'example-index',
  dimension: 1024,
  metric: 'cosine',
  deletionProtection: 'enabled',
  spec : { serverless: { cloud: 'aws', region: 'us-west-2' }},
});

Node support

Previously, the TypeScript SDK supported all versions of Node >=14.0.0. With this release we've moved support to Node >=18.0.0 due to prior versions having reached end of life and security support for versions prior to 18.0.0.

Fixes

  • Fixed an issue where QueryByVectorValues type did not correctly represent sparseValues which closed issue #236. Thanks to @max-tano for reporting.

Full Changelog: v2.2.2...v3.0.0

v2.2.2 Release

01 Jun 00:32
Compare
Choose a tag to compare

This patch fixes a bug when instantiating multiple instances of Pinecone and using multiple API keys targeting different indexes. The singleton cache that resolves index addresses will no longer hang on to the first API key it used to describe an index.

What's Changed

New Contributors

Full Changelog: v2.2.1...v2.2.2

v.2.2.1 Release

10 May 20:30
Compare
Choose a tag to compare

This patch fixes an issue with using sourceTag as an argument without disabling runtime validations.

What's Changed

Full Changelog: v2.2.0...v2.2.1

v2.2.0 Release

27 Mar 22:45
Compare
Choose a tag to compare

sourceTag added to PineconeConfiguration

The SDK now supports optionally passing a sourceTag when instantiating the Pinecone client. This tag allows requests made by the SDK to be attributed via the user-agent.

import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone({ apiKey: 'my-api-key', sourceTag: 'my-source-tag' });

// Requests made from the client will now have this tag applied to the user-agent

What's Changed

  • Add sourceTag to PineconeConfiguration and additionalHeaders to data plane calls by @austin-denoble in #197

Full Changelog: v2.1.1...v2.2.0

v2.1.1 Release

26 Mar 15:10
Compare
Choose a tag to compare

Exports the ListResponse interface so it can be used by consumers of the client.

What's Changed

  • Export ListResponse type from generated core, add docstring for ListOptions by @austin-denoble in #210

Full Changelog: v2.1.0...v2.1.1