Current section

Files

Jump to
dspex lib dspex settings.ex
Raw

lib/dspex/settings.ex

defmodule DSPex.Settings do
@moduledoc """
Global settings and configuration for DSPex.
Manages DSPy settings and provides utilities for configuration management.
Migrated to Snakepit v0.4.3 API.
Note: Some advanced features not yet implemented in current DSPy bridge.
"""
alias DSPex.Utils.ID
@doc """
Configure global DSPy settings.
## Examples
DSPex.Settings.configure(
lm: lm_instance,
rm: retriever_instance,
trace: [],
explain: false
)
"""
def configure(_settings, opts \\ []) do
session_id = opts[:session_id] || ID.generate("settings")
# Use get_settings tool which returns current settings
case Snakepit.execute_in_session(session_id, "get_settings", %{}) do
{:ok, _current_settings} ->
# For now, just return OK - actual configure would need a tool
{:ok, :settings_read_only}
{:error, error} ->
{:error, error}
end
end
@doc """
Get current DSPy settings.
"""
def get_settings(opts \\ []) do
session_id = opts[:session_id] || ID.generate("get_settings")
case Snakepit.execute_in_session(session_id, "get_settings", %{}) do
{:ok, settings} -> {:ok, settings}
{:error, error} -> {:error, error}
end
end
@doc """
Context manager for temporary settings.
## Examples
DSPex.Settings.with_settings([trace: []], fn ->
# Code that runs with tracing enabled
DSPex.Modules.Predict.predict(sig, inputs)
end)
"""
def with_settings(_temp_settings, fun) when is_function(fun, 0) do
# Note: This requires save/restore functionality not yet in bridge
# For now, just execute the function
fun.()
end
@doc """
Enable or disable experimental features.
"""
def experimental(_feature, _enabled \\ true, _opts \\ []) do
# Not yet implemented in current bridge
{:error, :not_implemented}
end
@doc """
Configure caching behavior.
"""
def configure_cache(_cache_opts, _opts \\ []) do
# Not yet implemented in current bridge
{:error, :not_implemented}
end
end