Current section
Files
Jump to
Current section
Files
lib/snakebridge_generated/dspy/clients/cache/cache.ex
# Generated by SnakeBridge v0.12.0 - DO NOT EDIT MANUALLY
# Regenerate with: mix compile
# Library: dspy 3.1.2
# Python module: dspy.clients.cache
# Python class: Cache
defmodule Dspy.Clients.Cache.Cache do
def __snakebridge_python_name__, do: "dspy.clients.cache"
def __snakebridge_python_class__, do: "Cache"
def __snakebridge_library__, do: "dspy"
@opaque t :: SnakeBridge.Ref.t()
@spec new(boolean(), boolean(), String.t(), list(term()), keyword()) ::
{:ok, SnakeBridge.Ref.t()} | {:error, Snakepit.Error.t()}
def new(enable_disk_cache, enable_memory_cache, disk_cache_dir, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_class(
__MODULE__,
:__init__,
[enable_disk_cache, enable_memory_cache, disk_cache_dir] ++ List.wrap(args),
opts
)
end
@spec cache_key(SnakeBridge.Ref.t(), %{optional(String.t()) => term()}, list(term()), keyword()) ::
{:ok, String.t()} | {:error, Snakepit.Error.t()}
def cache_key(ref, request, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_method(ref, :cache_key, [request] ++ List.wrap(args), opts)
end
@spec get(SnakeBridge.Ref.t(), %{optional(String.t()) => term()}, list(term()), keyword()) ::
{:ok, term()} | {:error, Snakepit.Error.t()}
def get(ref, request, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_method(ref, :get, [request] ++ List.wrap(args), opts)
end
@spec load_memory_cache(SnakeBridge.Ref.t(), String.t(), list(term()), keyword()) ::
{:ok, nil} | {:error, Snakepit.Error.t()}
def load_memory_cache(ref, filepath, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_method(ref, :load_memory_cache, [filepath] ++ List.wrap(args), opts)
end
@spec put(
SnakeBridge.Ref.t(),
%{optional(String.t()) => term()},
term(),
list(term()),
keyword()
) :: {:ok, nil} | {:error, Snakepit.Error.t()}
def put(ref, request, value, args, opts \\ []) do
{args, opts} = SnakeBridge.Runtime.normalize_args_opts(args, opts)
SnakeBridge.Runtime.call_method(ref, :put, [request, value] ++ List.wrap(args), opts)
end
@spec reset_memory_cache(SnakeBridge.Ref.t(), keyword()) ::
{:ok, nil} | {:error, Snakepit.Error.t()}
def reset_memory_cache(ref, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :reset_memory_cache, [], opts)
end
@spec save_memory_cache(SnakeBridge.Ref.t(), String.t(), keyword()) ::
{:ok, nil} | {:error, Snakepit.Error.t()}
def save_memory_cache(ref, filepath, opts \\ []) do
SnakeBridge.Runtime.call_method(ref, :save_memory_cache, [filepath], opts)
end
end