Releases: pinecone-io/pinecone-ts-client
Release v5.1.1
Fixes an issue where the typing for the upsertRecords
method did not accept _id
as an object argument. The _id
and _score
values are now properly returned from the searchRecords
method instead of mapped values.
What's Changed
- Fix
_id
and_score
in records APIs by @austin-denoble in #334
Full Changelog: v5.1.0...v5.1.1
Release v5.1.0
Features
Indexes with Integrated Inference
This release adds a new createIndexForModel
method as well as upsertRecords
, and searchRecords
methods. Together these methods provide a way for you to easily store your data and let us manage the process of creating embeddings. To learn about available models, see the Model Gallery.
import { Pinecone } from '@pinecone-database/pinecone';
// 1. Instantiate the Pinecone client
const pc = new Pinecone();
// 2. Create an index configured for use with a particular model
await pc.createIndexForModel({
name: 'my-integrated-index',
cloud: 'aws',
region: 'us-east-1',
embed: {
model: 'multilingual-e5-large',
fieldMap: { text: 'chunk_text' },
},
waitUntilReady: true,
});
// 3. Instantiate an Index client with a namespace
const namespace = pc.index('my-integrated-index').namespace('my-namespace');
// 4. Upsert records
await namespace.upsertRecords([
{
id: 'rec1',
chunk_text:
"Apple's first product, the Apple I, was released in 1976 and was hand-built by co-founder Steve Wozniak.",
category: 'product',
},
{
id: 'rec2',
chunk_text:
'Apples are a great source of dietary fiber, which supports digestion and helps maintain a healthy gut.',
category: 'nutrition',
},
{
id: 'rec3',
chunk_text:
'Apples originated in Central Asia and have been cultivated for thousands of years, with over 7,500 varieties available today.',
category: 'cultivation',
},
{
id: 'rec4',
chunk_text:
'In 2001, Apple released the iPod, which transformed the music industry by making portable music widely accessible.',
category: 'product',
},
{
id: 'rec5',
chunk_text:
'Apple went public in 1980, making history with one of the largest IPOs at that time.',
category: 'milestone',
},
{
id: 'rec6',
chunk_text:
'Rich in vitamin C and other antioxidants, apples contribute to immune health and may reduce the risk of chronic diseases.',
category: 'nutrition',
},
{
id: 'rec7',
chunk_text:
"Known for its design-forward products, Apple's branding and market strategy have greatly influenced the technology sector and popularized minimalist design worldwide.",
category: 'influence',
},
{
id: 'rec8',
chunk_text:
'The high fiber content in apples can also help regulate blood sugar levels, making them a favorable snack for people with diabetes.',
category: 'nutrition',
},
]);
// 5. Search for similar records
const response = await namespace.searchRecords({
query: {
topK: 3,
inputs: { text: 'Apple corporation' },
},
fields: ['chunk_text'],
rerank: {
model: 'bge-reranker-v2-m3',
rankFields: ['chunk_text'],
topN: 3,
},
});
New Assistant features
There are a few new fields available for working with Assistants. You can now pass messages
and topK
with context
requests. You can also request use jsonResponse
and includeHighlights
in chat
methods. The jsonResponse
boolean allows you to return content in a JSON format, while includeHighlights
let's you include additional contextual information from source references.
What's Changed
- Implement integrated inference by @austin-denoble in #331
- Implement additional Assistant features by @austin-denoble in #333
Full Changelog: v5.0.2...v5.1.0
Release v5.0.2
Types Embedding
and EmbeddingsListUsage
are now exported from the top of the client package.
Full Changelog: v5.0.1...v5.0.2
Release v5.0.1
What's Changed
- Remove
EmbeddingsList
custom class by @austin-denoble in #330
Full Changelog: v5.0.0...v5.0.1
Release v5.0.0
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
- Generate core for
2025-01
, implement Assistant base by @austin-denoble @aulorbe in #322 - Implement sparse index support by @austin-denoble in #327
- Implement Assistant chat streaming by @austin-denoble in #328
- Merge
release-candidate/2025-01
->main
for v5.0.0 by @austin-denoble in #329
Full Changelog: 4.1.0...v5.0.0
4.1.0
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 toexternal-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 inexternal-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
- @kehanzhang made their first contribution in #314
Full Changelog: v4.0.0...4.1.0
v4.0.0
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
Fixes
- Remove extra logging from getFetch() s/o @maxmetcalfe in #280
- Some general fixes/internal enhancements to CI workflows
New Contributors
- @maxmetcalfe made their first contribution in #280
Full Changelog: 3.0.2...v3.0.3
3.0.2
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
- @anawishnoff made their first contribution in #245
Full Changelog: v3.0.1...3.0.2
v3.0.1
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