Skip to content

Releases: pinecone-io/pinecone-ts-client

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

v2.1.0 Release

06 Mar 20:44
Compare
Choose a tag to compare

Listing record ids by prefix in a namespace (for serverless indexes)

We've implemented SDK support for a new data plane endpoint used to list ids by prefix in a given namespace. If no prefix or an empty string is passed, this can be used to list all ids in a namespace.

The index class now has a listPaginated function. With clever assignment of record ids, this can be used to help model hierarchical relationships between different records such as when you have embeddings for multiple chunks or fragments related to the same document.

You can fetch each page of results with listPaginated.

const pc = new Pinecone();
const index = pc.index('my-index').namespace('my-namespace');

const results = await index.listPaginated({ prefix: 'doc1#' });
console.log(results);
// {
//   vectors: [
//     { id: 'doc1#01' }, { id: 'doc1#02' }, { id: 'doc1#03' },
//     { id: 'doc1#04' }, { id: 'doc1#05' },  { id: 'doc1#06' },
//     { id: 'doc1#07' }, { id: 'doc1#08' }, { id: 'doc1#09' },
//     ...
//   ],
//   pagination: {
//     next: 'eyJza2lwX3Bhc3QiOiJwcmVUZXN0LS04MCIsInByZWZpeCI6InByZVRlc3QifQ=='
//   },
//   namespace: 'my-namespace',
//   usage: { readUnits: 1 }
// }

// Fetch the next page of results
await index.listPaginated({
  prefix: 'doc1#',
  paginationToken: results.pagination.next,
});

Fixes

  • types(update): wrap metadata param in Partial by @omikader in #199

Chores

New Contributors

Full Changelog: v2.0.1...v2.1.0