# Generated by SnakeBridge v0.14.0 - DO NOT EDIT MANUALLY # Regenerate with: mix compile # Library: dspy 3.1.2 # Python module: dspy.dsp.utils.dpr defmodule Dspy.Dsp.Utils.Dpr do @moduledoc """ Source: DPR Implementation from Facebook Research https://github.com/facebookresearch/DPR/tree/master/dpr Original license: https://github.com/facebookresearch/DPR/blob/main/LICENSE ## Version - Requested: 3.1.2 - Observed at generation: 3.1.2 ## Runtime Options All functions accept a `__runtime__` option for controlling execution behavior: Dspy.Dsp.Utils.Dpr.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.Dsp.Utils.Dpr.predict(data, __runtime__: [timeout_profile: :ml_inference]) # Or explicit timeout Dspy.Dsp.Utils.Dpr.predict(data, __runtime__: [timeout: 600_000]) # Route to a pool and enforce strict affinity Dspy.Dsp.Utils.Dpr.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.dsp.utils.dpr" @doc false def __snakebridge_library__, do: "dspy" @doc """ Source: DPR Implementation from Facebook Research https://github.com/facebookresearch/DPR/tree/master/dpr Original license: https://github.com/facebookresearch/DPR/blob/main/LICENSE ## Parameters - `text` (term()) ## Returns - `term()` """ @spec dpr_normalize(term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def dpr_normalize(text, opts \\ []) do SnakeBridge.Runtime.call(__MODULE__, "DPR_normalize", [text], opts) end @doc """ Source: DPR Implementation from Facebook Research https://github.com/facebookresearch/DPR/tree/master/dpr Original license: https://github.com/facebookresearch/DPR/blob/main/LICENSE ## Parameters - `text` (term()) ## Returns - `term()` """ @spec dpr_tokenize(term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def dpr_tokenize(text, opts \\ []) do SnakeBridge.Runtime.call(__MODULE__, "DPR_tokenize", [text], opts) end @doc """ Source: DPR Implementation from Facebook Research https://github.com/facebookresearch/DPR/tree/master/dpr Original license: https://github.com/facebookresearch/DPR/blob/main/LICENSE ## Parameters - `tokenized_answers` (term()) - `text` (term()) ## Returns - `term()` """ @spec has_answer(term(), term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def has_answer(tokenized_answers, text, opts \\ []) do SnakeBridge.Runtime.call(__MODULE__, :has_answer, [tokenized_answers, text], opts) end @doc """ Returns each occurrence of an answer as (offset, endpos) in terms of *characters*. ## Parameters - `tokenized_answers` (term()) - `text` (term()) ## Returns - `term()` """ @spec locate_answers(term(), term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def locate_answers(tokenized_answers, text, opts \\ []) do SnakeBridge.Runtime.call(__MODULE__, :locate_answers, [tokenized_answers, text], opts) end @doc """ Source: DPR Implementation from Facebook Research https://github.com/facebookresearch/DPR/tree/master/dpr Original license: https://github.com/facebookresearch/DPR/blob/main/LICENSE ## Returns - `Dspy.Dsp.Utils.Dpr.SimpleTokenizer.t()` """ @spec s_tokenizer() :: {:ok, Dspy.Dsp.Utils.Dpr.SimpleTokenizer.t()} | {:error, Snakepit.Error.t()} def s_tokenizer() do SnakeBridge.Runtime.get_module_attr(__MODULE__, "STokenizer") end @doc """ Strips accents from a piece of text. ## Parameters - `text` (term()) ## Returns - `term()` """ @spec strip_accents(term(), keyword()) :: {:ok, term()} | {:error, Snakepit.Error.t()} def strip_accents(text, opts \\ []) do SnakeBridge.Runtime.call(__MODULE__, :strip_accents, [text], opts) end end