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 ¶
Types ¶
type CostLine ¶
type CostLine struct {
Model string `json:"model"`
Old float64 `json:"old"`
New float64 `json:"new"`
Delta float64 `json:"delta"`
// 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 `json:"approx"`
// CacheSupported is true when Model's provider family has a modeled
// prompt-caching discount (see internal/cost.IsCacheSupported). When
// false, CachedOld/CachedNew/CachedDelta are zero and should be ignored
// rather than read as "no savings".
CacheSupported bool `json:"cache_supported"`
// CachedOld/CachedNew/CachedDelta project cost the same way as
// Old/New/Delta, but assume the whole prompt is cached: the first of the
// 100k invocations pays the provider's cache-write price, the rest pay
// the cheaper cache-read price. Only meaningful when CacheSupported.
CachedOld float64 `json:"cached_old,omitempty"`
CachedNew float64 `json:"cached_new,omitempty"`
CachedDelta float64 `json:"cached_delta,omitempty"`
}
CostLine is one model row of the cost projection.
type Diff ¶
type Diff struct {
TokenDelta int `json:"token_delta"`
TokenPercent float64 `json:"token_percent"`
Costs []CostLine `json:"costs"`
AddedSections []string `json:"added_sections,omitempty"`
RemovedSections []string `json:"removed_sections,omitempty"`
ModifiedVars []VarChange `json:"modified_vars,omitempty"`
AddedVars []string `json:"added_vars,omitempty"`
RemovedVars []string `json:"removed_vars,omitempty"`
// SemanticSimilarity is the cosine similarity, in [-1, 1], between the
// old and new prompt body embeddings. Nil unless semantic diffing ran.
SemanticSimilarity *float64 `json:"semantic_similarity,omitempty"`
}
Diff is the result of comparing two versions of a prompt.
Click to show internal directories.
Click to hide internal directories.