LengthRatioGuard

class LengthRatioGuard(maxRatio: Double = DEFAULT_MAX_RATIO) : MatchGuard

Rejects matches where one prompt is far longer than the other.

A one-line question and a three-paragraph one rarely want the same answer even when they cover the same topic, and length is a decent proxy for how much detail was asked for. It is only a proxy, though — "python list reverse" and "How do I reverse a list in Python?" are a four-fold difference in tokens and the same question — so this guard is not part of MatchGuards.standard. Reach for it through MatchGuards.strict, or add it directly, when your traffic mixes short queries with long ones and you would rather pay for the call.

Constructors

Link copied to clipboard
constructor(maxRatio: Double = DEFAULT_MAX_RATIO)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val name: String

Short stable identifier, surfaced in dev.kmemo.CacheLookup.Miss.detail.

Functions

Link copied to clipboard
open override fun evaluate(query: String, candidate: String): GuardVerdict

Judges serving the response cached for candidate in answer to query.