Skip to content

Selectors

LlamaIndex BaseSelectors. Single-route uses one Choice; multi-route uses one Noul per option.

JevSingleSelector

Argument Default Notes
provider "typesafe" "typesafe" or "openrouter"
model "jev-latest" Remapped to ~typesafe/... on OpenRouter
default_index None Fallback index if Jev fails; otherwise raise
confidence_threshold None Low / missing confidence is failure
timeout_s 2.5 HTTP timeout
api_key env var Constructor-only; see providers

Bases: _JevSelectorBase

Pick exactly one choice with a Jev Choice question.

Fail-closed: an API error, an out-of-schema choice, or a confidence miss either raises or (if default_index is set) returns that index.

Create a single-choice selector.

Parameters:

Name Type Description Default
api_key str | None

TypeSafe or OpenRouter key. Falls back to TYPESAFE_API_KEY or OPENROUTER_API_KEY based on provider.

None
model str

TypeSafe model id; remapped to ~typesafe/... on OpenRouter.

'jev-latest'
default_index int | None

Selection index if Jev fails. If omitted, failures raise.

None
confidence_threshold float | None

Treat a Choice below this confidence as failure (raise or default_index).

None
timeout_s float

HTTP timeout forwarded to the client.

2.5
provider str

typesafe or openrouter.

'typesafe'
Source code in packages/llama-index-selectors-jev/llama_index/selectors/jev/base.py
def __init__(
    self,
    api_key: str | None = None,
    model: str = "jev-latest",
    default_index: int | None = None,
    confidence_threshold: float | None = None,
    timeout_s: float = 2.5,
    provider: str = "typesafe",
) -> None:
    """Create a single-choice selector.

    Args:
        api_key: TypeSafe or OpenRouter key. Falls back to
            ``TYPESAFE_API_KEY`` or ``OPENROUTER_API_KEY`` based on
            ``provider``.
        model: TypeSafe model id; remapped to ``~typesafe/...`` on
            OpenRouter.
        default_index: Selection index if Jev fails. If omitted,
            failures raise.
        confidence_threshold: Treat a Choice below this confidence as
            failure (raise or ``default_index``).
        timeout_s: HTTP timeout forwarded to the client.
        provider: ``typesafe`` or ``openrouter``.
    """
    super().__init__()
    self.provider = provider
    api_key = resolve_api_key(api_key, provider=provider)
    self.model = model
    self.default_index = default_index
    self.confidence_threshold = confidence_threshold
    self.timeout_s = timeout_s
    self._client, self._async_client = make_clients(
        provider, api_key, model, timeout_s
    )

JevMultiSelector

Argument Default Notes
provider "typesafe" "typesafe" or "openrouter"
model "jev-latest" Remapped to ~typesafe/... on OpenRouter
threshold 0.5 Keep options with noul > threshold
default_index None API-error fallback only, not empty-Noul
timeout_s 2.5 HTTP timeout
api_key env var Constructor-only; see providers

Bases: _JevSelectorBase

Keep every choice whose Noul is above threshold.

One system_one call carries one Noul per option (chunked at 255). If nothing clears the threshold, return the single highest-noul choice. default_index is used only when the API call itself fails.

Create a multi-choice selector.

Parameters:

Name Type Description Default
api_key str | None

TypeSafe or OpenRouter key. Falls back to TYPESAFE_API_KEY or OPENROUTER_API_KEY based on provider.

None
model str

TypeSafe model id; remapped to ~typesafe/... on OpenRouter.

'jev-latest'
threshold float

Keep options whose Noul is strictly above this value.

0.5
default_index int | None

Selection index if the API call fails. Not used when every Noul is at or below threshold.

None
timeout_s float

HTTP timeout forwarded to the client.

2.5
provider str

typesafe or openrouter.

'typesafe'
Source code in packages/llama-index-selectors-jev/llama_index/selectors/jev/base.py
def __init__(
    self,
    api_key: str | None = None,
    model: str = "jev-latest",
    threshold: float = 0.5,
    default_index: int | None = None,
    timeout_s: float = 2.5,
    provider: str = "typesafe",
) -> None:
    """Create a multi-choice selector.

    Args:
        api_key: TypeSafe or OpenRouter key. Falls back to
            ``TYPESAFE_API_KEY`` or ``OPENROUTER_API_KEY`` based on
            ``provider``.
        model: TypeSafe model id; remapped to ``~typesafe/...`` on
            OpenRouter.
        threshold: Keep options whose Noul is strictly above this
            value.
        default_index: Selection index if the API call fails. Not used
            when every Noul is at or below ``threshold``.
        timeout_s: HTTP timeout forwarded to the client.
        provider: ``typesafe`` or ``openrouter``.
    """
    super().__init__()
    self.provider = provider
    api_key = resolve_api_key(api_key, provider=provider)
    self.model = model
    self.threshold = threshold
    self.default_index = default_index
    self.timeout_s = timeout_s
    self._client, self._async_client = make_clients(
        provider, api_key, model, timeout_s
    )