Skip to main content
Version: 2.0.0

PipelineRun class - checkpoint()

The PipelineRun class captures the generative output for a unique invocation of a generative pipeline. checkpoint() is a method under this class.

checkpoint()

checkpoint() tracks the inputs, outputs, and duration it takes to run a step in a generative pipeline relative to the last time checkpoint() was called.

Arguments

inputs

Rather than passing inputs to a measured function, with checkpoint() you must directly specify the inputs to the step.

outputs

The outputs that you want to track for that checkpoint.

stepInfo

An object containing additional information about the step. The most important key/value pair in the stepInfo is the context key, which attaches more metadata to the step.

Read about the typing for the context key here.

Examples

typescript
import { init, Pipeline } from "@gentrace/core";
import { initPlugin as initOpenAIPlugin } from "@gentrace/openai";
import { User } from "../models";
 
// This function globally initializes Gentrace with the appropriate
// credentials. Constructors like Pipeline() will transparently use
// these credentials to authenticate with Gentrace.
init({
apiKey: process.env.GENTRACE_API_KEY
});
 
const openaiPlugin = await initOpenAIPlugin({
apiKey: process.env.OPENAI_KEY,
});
 
const pipeline = new Pipeline({
slug: "create-embedding",
plugins: {
openai: openaiPlugin,
pinecone: pineconePlugin
},
});
 
const runner = pipeline.start()
 
const openai = runner.openai;
 
const userId = "550e8400-e29b-41d4-a716-446655440000";
const gentraceOrgId = "c9a646d3-9c61-4cb7-bfcd-ee2522c8f633";
 
// Custom application logic
const user = await User.findOne({
where: {
id: userId,
orgId: gentraceOrgId,
}
});
 
const name = user.name;
 
runner.checkpoint({
inputs: { userId, orgId: gentraceOrgId },
outputs: { name },
});
 
const embeddingResponse = await openai.embeddings.create({
model: 'text-embedding-ada-002',
input: `Human, software engineer, Gentrace: ${name}!`,
});
 
await runner.submit();