codebook_diff: Compare two codebooks

View source: R/codebook.R

codebook_diffR Documentation

Compare two codebooks

Description

Create a compact diff of two foundry_codebook objects, including both hashes, a unified diff of instructions, and field-level changes for schema properties and examples. Assign the result to inspect it without console output, or print it to display the diff.

Usage

codebook_diff(old, new)

## S3 method for class 'foundry_codebook_diff'
format(x, ...)

## S3 method for class 'foundry_codebook_diff'
print(x, ...)

Arguments

old, new

foundry_codebook objects to compare.

x

A foundry_codebook_diff object.

...

Unused.

Value

codebook_diff() returns a character vector of diff lines with class foundry_codebook_diff. format() returns the plain character vector. print() displays the lines and invisibly returns x.

Examples

old <- foundry_codebook(
  name = "support-sentiment",
  version = "1.0.0",
  instructions = "Label the sentiment of support tickets.",
  schema = foundry_schema(sentiment = type_enum(values = c("pos", "neg")))
)
new <- foundry_codebook(
  name = "support-sentiment",
  version = "1.1.0",
  instructions = "Label the sentiment and urgency of support tickets.",
  schema = foundry_schema(
    sentiment = type_enum(values = c("pos", "neg")),
    urgent = type_boolean()
  )
)
diff <- codebook_diff(old, new)
print(diff)

foundryR documentation built on Sept. 25, 2026, 1:10 a.m.