ReqLLM. Cache behaviour
(ReqLLM v1.14.0)
View Source
Application-layer response cache hooks for generation requests.
ReqLLM does not ship a cache store. Instead, callers can pass a module that
implements this behaviour to :cache and back it with Cachex, Nebulex, ETS,
Redis, or any custom storage.
Summary
Types
@type request() :: %{ operation: :chat | :object, context: ReqLLM.Context.t(), schema: map() | nil }
Callbacks
@callback generate_key( model :: LLMDB.Model.t(), request :: request(), opts :: keyword() | map() ) :: term()
@callback get(key :: term(), opts :: keyword() | map()) :: {:ok, ReqLLM.Response.t()} | {:error, term()}
@callback put( key :: term(), value :: ReqLLM.Response.t(), ttl :: non_neg_integer() | nil, opts :: keyword() | map() ) :: :ok | {:error, term()}
Functions
@spec fetch( LLMDB.Model.t(), :chat | :object, ReqLLM.Context.t(), keyword(), map() | nil ) :: {:hit, ReqLLM.Response.t(), %{backend: module(), key: term()}} | {:miss, %{backend: module(), key: term()} | nil}
@spec store(%{backend: module(), key: term()} | nil, ReqLLM.Response.t(), keyword()) :: ReqLLM.Response.t()
@spec stream_response(ReqLLM.Response.t(), LLMDB.Model.t(), ReqLLM.Context.t()) :: ReqLLM.StreamResponse.t()