Skip to main content
Version: 4.7.28

PipelineRun class - Pinecone handler

The PipelineRun class instance exposes a Pinecone handler that simplifies capturing generative output in Gentrace.

For a guided walkthrough of the Gentrace Pinecone integration, visit our Pinecone docs.

Usage

Create a handle in two ways to communicate with Pinecone.

Simple

typescript
import { init, Pipeline } from "@gentrace/core";
import { Pinecone } from "@gentrace/pinecone";
import { DEFAULT_VECTOR } from "../constants";
 
init({
apiKey: process.env.GENTRACE_API_KEY
});
 
const pinecone = new Pinecone({
apiKey: process.env.PINECONE_API_KEY!,
});
 
const index = await pinecone.Index("openai-trec");
 
const queryResponse = await index.query({
includeValues: true,
topK: 3,
vector: DEFAULT_VECTOR,
pipelineSlug: "pinecone-example",
});
 
console.log("queryResponse", queryResponse);

Advanced

The advanced method allows you to attach multiple steps to a single PipelineRun instance.

typescript
const runner = pipeline.start();
 
const pinecone = runner.pinecone;
 
const index = await pinecone.Index("openai-trec");
 
const queryResponse = await index.query({
includeValues: true,
topK: 3,
vector: DEFAULT_VECTOR,
});
 
await runner.submit();

Fetch

The Index.fetch() method is a wrapper around the equivalent Pinecone SDK method.

Arguments

The below key-value pairs augment the defaults.

pipelineSlug?: string (UUID)

If you're using the Simple SDK, you can specify the pipeline slug here.

gentrace: object

This object contains Gentrace context. Learn about context here.

Return value

Resolves to the original Pinecone response. If you're using the simple SDK, the response has an additional pipelineRunId.

pipelineRunId?: string (UUID)

The pipelineRunId is a unique identifier for the run. It can be used to retrieve the run later.

Examples

typescript
const runner = pipeline.start();
 
const pinecone = runner.pinecone;
 
const index = await pinecone.index("my-index");
 
const response = await index.fetch(["8248"], {
gentrace: {
metadata: {
gitSha: {
type: "string",
value: "6cb2a7e4f5765d92d95728f1746b9a1a59d8ad13"
}
}
}
});
 
await runner.submit();

Upsert

The Index.upsert() method is a wrapper around the equivalent Pinecone SDK method.

Arguments

The below key-value pairs augment the defaults.

vectors: Vector[]

Same as the underlying Pinecone SDK, this parameter can be a single vector or an array of vectors that you want to upsert.

options: object

This object contain Gentrace-specific options.

  • pipelineSlug? If you're using the Simple SDK, you can specify the pipeline slug here.

  • gentrace? This object contains Gentrace context. Learn about context here.

Return value

Resolves to the original Pinecone response. If you're using the simple SDK, the response has an additional pipelineRunId.

pipelineRunId?: string (UUID)

The pipelineRunId is a unique identifier for the run. It can be used to retrieve the run later.

Examples

typescript
const runner = pipeline.start();
 
const pinecone = runner.pinecone;
 
const index = await pinecone.index("my-index");
 
const upsert = await index.upsert([
{
id: String(Math.floor(Math.random() * 10000)),
values: DEFAULT_VECTOR,
},
]);
 
await runner.submit();

Query

The Index.query() method is a wrapper around the equivalent Pinecone SDK method.

Arguments

The below key-value pairs augment the defaults for the first parameter.

pipelineSlug?: string

If you're using the Simple SDK, you can specify the pipeline slug here.

gentrace?: object This object contains Gentrace context. Learn about context here.

Return value

Resolves to the original Pinecone response. If you're using the simple SDK, the response has an additional pipelineRunId.

pipelineRunId?: string (UUID)

The pipelineRunId is a unique identifier for the run. It can be used to retrieve the run later.

Examples

typescript
const runner = pipeline.start();
 
const pinecone = runner.pinecone;
 
const index = await pinecone.index("my-index");
 
const queryResponse = await index.query({
includeValues: true,
topK: 3,
vector: DEFAULT_VECTOR,
pipelineSlug: "pinecone-example",
});
 
await runner.submit();

Delete

The Index.deleteOne() method is a wrapper around the equivalent Pinecone SDK method.

Arguments

The below key-value pairs augment the defaults.

vectorId: string

Same as the underlying Pinecone SDK, this parameter is the ID of the vector you want to delete.

options: object

This object contain Gentrace-specific options.

  • pipelineSlug?: string If you're using the Simple SDK, you can specify the pipeline slug here.

  • gentrace?: object This object contains Gentrace context. Learn about context here.

Return value

Resolves to the original Pinecone response. If you're using the simple SDK, the response has an additional pipelineRunId.

pipelineRunId?: string (UUID)

The pipelineRunId is a unique identifier for the run. It can be used to retrieve the run later.

Examples

typescript
const runner = pipeline.start();
 
const pinecone = runner.pinecone;
 
const index = await pinecone.index("my-index");
 
const response = await index.deleteOne("8248");
 
await runner.submit();