# Generated by SnakeBridge v0.13.0 - DO NOT EDIT MANUALLY # Regenerate with: mix compile # Library: dspy 3.1.2 # Python module: dspy.clients defmodule Dspy.Clients do @moduledoc """ Submodule bindings for `dspy.clients`. ## Version - Requested: 3.1.2 - Observed at generation: 3.1.2 ## Runtime Options All functions accept a `__runtime__` option for controlling execution behavior: Dspy.Clients.some_function(args, __runtime__: [timeout: 120_000]) ### Supported runtime options - `:timeout` - Call timeout in milliseconds (default: 120,000ms / 2 minutes) - `:timeout_profile` - Use a named profile (`:default`, `:ml_inference`, `:batch_job`, `:streaming`) - `:stream_timeout` - Timeout for streaming operations (default: 1,800,000ms / 30 minutes) - `:session_id` - Override the session ID for this call - `:pool_name` - Target a specific Snakepit pool (multi-pool setups) - `:affinity` - Override session affinity (`:hint`, `:strict_queue`, `:strict_fail_fast`) ### Timeout Profiles - `:default` - 2 minute timeout for regular calls - `:ml_inference` - 10 minute timeout for ML/LLM workloads - `:batch_job` - Unlimited timeout for long-running jobs - `:streaming` - 2 minute timeout, 30 minute stream_timeout ### Example with timeout override # For a long-running ML inference call Dspy.Clients.predict(data, __runtime__: [timeout_profile: :ml_inference]) # Or explicit timeout Dspy.Clients.predict(data, __runtime__: [timeout: 600_000]) # Route to a pool and enforce strict affinity Dspy.Clients.predict(data, __runtime__: [pool_name: :strict_pool, affinity: :strict_queue]) See `SnakeBridge.Defaults` for global timeout configuration. """ @doc false def __snakebridge_python_name__, do: "dspy.clients" @doc false def __snakebridge_library__, do: "dspy" @doc """ Configure the cache for DSPy. ## Parameters - `enable_disk_cache` - Whether to enable on-disk cache. - `enable_memory_cache` - Whether to enable in-memory cache. - `disk_cache_dir` - The directory to store the on-disk cache. - `disk_size_limit_bytes` - The size limit of the on-disk cache. - `memory_max_entries` - The maximum number of entries in the in-memory cache. To allow the cache to grow without bounds, set this parameter to `math.inf` or a similar value. ## Returns - `term()` """ @spec configure_cache() :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec configure_cache(keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec configure_cache(term()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec configure_cache(term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec configure_cache(term(), term()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec configure_cache(term(), term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec configure_cache(term(), term(), term()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec configure_cache(term(), term(), term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec configure_cache(term(), term(), term(), term()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec configure_cache(term(), term(), term(), term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec configure_cache(term(), term(), term(), term(), integer()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec configure_cache(term(), term(), term(), term(), integer(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def configure_cache() do SnakeBridge.Runtime.call(__MODULE__, :configure_cache, [], []) end def configure_cache(opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call(__MODULE__, :configure_cache, [], opts) end def configure_cache(enable_disk_cache) do SnakeBridge.Runtime.call(__MODULE__, :configure_cache, [enable_disk_cache], []) end def configure_cache(enable_disk_cache, opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call(__MODULE__, :configure_cache, [enable_disk_cache], opts) end def configure_cache(enable_disk_cache, enable_memory_cache) do SnakeBridge.Runtime.call( __MODULE__, :configure_cache, [enable_disk_cache, enable_memory_cache], [] ) end def configure_cache(enable_disk_cache, enable_memory_cache, opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call( __MODULE__, :configure_cache, [enable_disk_cache, enable_memory_cache], opts ) end def configure_cache(enable_disk_cache, enable_memory_cache, disk_cache_dir) do SnakeBridge.Runtime.call( __MODULE__, :configure_cache, [enable_disk_cache, enable_memory_cache, disk_cache_dir], [] ) end def configure_cache(enable_disk_cache, enable_memory_cache, disk_cache_dir, opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call( __MODULE__, :configure_cache, [enable_disk_cache, enable_memory_cache, disk_cache_dir], opts ) end def configure_cache( enable_disk_cache, enable_memory_cache, disk_cache_dir, disk_size_limit_bytes ) do SnakeBridge.Runtime.call( __MODULE__, :configure_cache, [enable_disk_cache, enable_memory_cache, disk_cache_dir, disk_size_limit_bytes], [] ) end def configure_cache( enable_disk_cache, enable_memory_cache, disk_cache_dir, disk_size_limit_bytes, opts ) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call( __MODULE__, :configure_cache, [enable_disk_cache, enable_memory_cache, disk_cache_dir, disk_size_limit_bytes], opts ) end def configure_cache( enable_disk_cache, enable_memory_cache, disk_cache_dir, disk_size_limit_bytes, memory_max_entries ) do SnakeBridge.Runtime.call( __MODULE__, :configure_cache, [ enable_disk_cache, enable_memory_cache, disk_cache_dir, disk_size_limit_bytes, memory_max_entries ], [] ) end def configure_cache( enable_disk_cache, enable_memory_cache, disk_cache_dir, disk_size_limit_bytes, memory_max_entries, opts ) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call( __MODULE__, :configure_cache, [ enable_disk_cache, enable_memory_cache, disk_cache_dir, disk_size_limit_bytes, memory_max_entries ], opts ) end @doc """ Python binding for `dspy.clients.disable_litellm_logging`. ## Returns - `term()` """ @spec disable_litellm_logging(keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def disable_litellm_logging(opts \\ []) do SnakeBridge.Runtime.call(__MODULE__, :disable_litellm_logging, [], opts) end @doc """ Python binding for `dspy.clients.enable_litellm_logging`. ## Returns - `term()` """ @spec enable_litellm_logging(keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def enable_litellm_logging(opts \\ []) do SnakeBridge.Runtime.call(__MODULE__, :enable_litellm_logging, [], opts) end @doc """ The global history shared across all LMs. ## Parameters - `n` (integer() default: 1) ## Returns - `term()` """ @spec inspect_history() :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec inspect_history(keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec inspect_history(integer()) :: {:ok, term()} | {:error, Snakepit.Error.t()} @spec inspect_history(integer(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def inspect_history() do SnakeBridge.Runtime.call(__MODULE__, :inspect_history, [], []) end def inspect_history(opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call(__MODULE__, :inspect_history, [], opts) end def inspect_history(n) do SnakeBridge.Runtime.call(__MODULE__, :inspect_history, [n], []) end def inspect_history(n, opts) when is_list(opts) and (opts == [] or (is_tuple(hd(opts)) and tuple_size(hd(opts)) == 2 and is_atom(elem(hd(opts), 0)))) do SnakeBridge.Runtime.call(__MODULE__, :inspect_history, [n], opts) end end