promptdiff

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package promptdiff computes structural and token diffs between two prompt versions, with README-matching output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CostLine

type CostLine struct {
	Model string
	Old   float64
	New   float64
	Delta float64
	// Approx is true when Model has no known BPE vocabulary, so the token
	// counts behind Old/New/Delta are approximated with cl100k_base rather
	// than the model's real tokenizer.
	Approx bool
}

CostLine is one model row of the cost projection.

type Diff

type Diff struct {
	TokenDelta      int
	TokenPercent    float64
	Costs           []CostLine
	AddedSections   []string
	RemovedSections []string
	ModifiedVars    []VarChange
	AddedVars       []string
	RemovedVars     []string
}

Diff is the result of comparing two versions of a prompt.

func Compare

func Compare(oldP, newP *prompt.Template) Diff

Compare diffs oldP -> newP.

type VarChange

type VarChange struct {
	From string
	To   string
}

VarChange records a variable that was renamed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL