Documentation
¶
Overview ¶
Package facts classifies which LLM provider a request went to, and gives the cache facts (accountant.EntryFacts) that provider's prompt cache has for a model. It is Cortex's own table, the host part of accountant/docs/cortex-wiring.md W6 (cortex-wiring.md's cached-prefix.md companion document is cited on each row). It matches the context-guru proxy's entryFacts (proxy/accountant_wire.go:229-246) exactly, minus the ping facts, which the caller in core/accounting applies on top.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func For ¶
func For(p Provider, model string, allMarksAsk1h bool) accountant.EntryFacts
For returns the accountant.EntryFacts for provider p and model, given allMarksAsk1h — whether EVERY raw cache_control mark in the forwarded body asked for the 1h tier. It does not know about keep-alive pings; the caller in core/accounting applies those on top, as entryFacts' PingStore lookup does in the proxy.
The 1h tier needs every raw mark to ask 1h, which a merged accountant.Breakpoint cannot express: a position can merge a 5m mark and a 1h mark into one Breakpoint{TTL:"1h"}. So callers pass wire.AllMarksAsk1h(raw) over the raw forwarded body, and must not derive this bool from the Breakpoint slice wire.Parse returns.
Types ¶
type Provider ¶
type Provider int
Provider is the LLM provider a request went to, as far as Cortex's cache-facts table distinguishes them. It is Cortex's own enum: the proxy uses bifrost's bschemas.ModelProvider, which core/accounting does not import: Cortex does not depend on context-guru, and bschemas is a context-guru dependency, not a Cortex one.
func Classify ¶
Classify says which provider's cache rules apply to a request, from its path alone. It uses wire.FormatOf, so this package and wire share one path table and cannot disagree. Like the proxy (explicitBreakpointProvider / modelinfo.HonoursCacheControl), it goes by the wire dialect, never by the hostname: a gateway that fronts several providers (LiteLLM, OpenRouter, Azure) still speaks one dialect, and the dialect decides the cache rules.
An unrecognized path is ProviderUnknown whatever the request's destination, even a host whose name contains "anthropic" or "openai", because a host name does not say which wire dialect the request uses.
A Chat or Responses body that carries cache_control marks (which Cortex's chat decoder, LiteLLM and OpenRouter accept for Claude models) still gets OpenAI cache facts (LifetimeUnknown), although wire.Parse finds its breakpoints. The proxy has the same gap.