Interface NaruCacheableContext
- All Known Implementing Classes:
NaruCacheableContext.DefaultNaruCacheableContext
This is an opt-in view of a request. Callers that do not implement
it keep passing a plain NaruModelRequest and providers that do not
consume it keep seeing exactly what they saw before; nothing here is on the
mandatory path.
Its purpose is to let a caller say what is stable without knowing how any
provider expresses caching. toRequest(Map) collapses the segments
back into the ordinary flat request, which is what a provider with no caching
support — or any provider whose mode is NaruCachingMode.AUTOMATIC_PREFIX
— actually consumes. Ordering is preserved exactly, because for automatic
prefix caching the ordering is the contract.
Segments are expected in stable-to-volatile order. NARU does not reorder them: silently moving a caller's "latest user turn" ahead of their indexed context would change the model's view of the conversation, and a caching layer is the last place that should be reordering prompts.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classFluent assembler.static final class -
Method Summary
Modifier and TypeMethodDescriptionstatic NaruCacheableContext.Builderbuilder()default booleanisEmpty()static NaruCacheableContextof(List<NaruContextSegment> segments) static NaruCacheableContextof(List<NaruContextSegment> segments, List<NaruToolDefinition> tools) Convenience for the common case: a stable head and a volatile tail, with the tool definitions folded in as their own cacheable segment.segments()default NaruModelRequestCollapse to the plain request shape.
-
Method Details
-
segments
List<NaruContextSegment> segments() -
isEmpty
default boolean isEmpty() -
toRequest
Collapse to the plain request shape. Cacheability is dropped here on purpose: the flat form carries no cache information at all, so any provider that does not implement caching translation gets byte-identical behaviour to a request built without segmentation. -
of
-
builder
-
of
Convenience for the common case: a stable head and a volatile tail, with the tool definitions folded in as their own cacheable segment.
-