Skip to content

Release v5.0.0

Compare
Choose a tag to compare
@austin-denoble austin-denoble released this 15 Feb 05:35
· 24 commits to main since this release

This version of the Pinecone Node SDK depends on version 2025-01 of the Pinecone API. You can read more about versioning here. This v5 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:

import { Pinecone } from '@pinecone-database/pinecone';
const pc = new Pinecone();

// create a sparse serverless index
await pc.createIndex({
  name: 'sample-index',
  vectorType: 'sparse',
  spec: {
    serverless: {
      cloud: 'aws',
      region: 'us-east-1',
    },
  },
});

// upsert sparse vectors to the index
const index = pc.index('sample-index');

const sparseVectors = [
  {
    id: '1',
    sparseValues: { indices: [0, 1], values: [0.236, 0.34] },
  },
  {
    id: '2',
    sparseValues: { indices: [0, 1], values: [0.345, 0.98] },
  },
];

await index.upsertVectors(sparseVectors);

Assistant support

Support has been added for working with Pinecone Assistants. Pinecone Assistant is a service that allows you to upload documents, ask questions, and receive responses that reference your documents. This is known as retrieval-augmented generation (RAG).

const pc = new Pinecone();

// create an assistant
await pc.createAssistant({
  name: 'test-assistant',
  instructions: 'respond to queries in english',
  region: 'us',
  metadata: { key: 'value' },
});

const assistant = pc.assistant('test-assistant');

// upload a file to the assistant
const file = await assistant.uploadFile({
  path: '/local/path/to/file.pdf',
  metadata: { key: 'value' },
});

// check on the status of the file
const fileStatus = await assistant.describeFile(file.id);
console.log(fileStatus.percentDone);

// chat with the assistant
const stream = await assistant.chatStream({
  messages: [{ role: 'user', content: 'What is the capital of France?' }],
});

// stream the response
for await (const chunk of stream) {
  if (chunk.type === 'content_chunk') {
    process.stdout.write(chunk.delta.content || '');
  }
}
});

What's Changed

Full Changelog: 4.1.0...v5.0.0