Skip to main content
Version: 4.6.7

PipelineRun class - checkpoint()

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

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.

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();

Arguments

inputs: object

info

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

outputs: object

stepInfo: object

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.