Documentation
¶
Overview ¶
Package cache implements a caching framework for LLM responses, mirroring langchain-core's caches. It provides a Cache interface, an in-memory implementation, and a wrapper that can be used to cache model calls keyed by the messages and model options.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface {
// Lookup returns a cached value for the key, or nil if not present.
Lookup(ctx context.Context, key Key) (*Value, error)
// Update stores a value for the key.
Update(ctx context.Context, key Key, value *Value) error
// Clear removes all entries.
Clear(ctx context.Context) error
}
Cache is the interface for a response cache.
type InMemory ¶
type InMemory struct {
// contains filtered or unexported fields
}
InMemory is a thread-safe in-memory cache.
type Key ¶
type Key struct {
// Model is the model identifier.
Model string
// Messages is a canonical serialization of the input messages.
Messages string
// Options is a canonical serialization of the relevant call options.
Options string
}
Key identifies a cached model call.
Click to show internal directories.
Click to hide internal directories.