Dm Invoker
[BETA] Modules concerning the decision model invokers used in Gen AI applications.
AnyJevDMInvoker(model_name, base_url, api_key=None, model_kwargs=None, decider_kwargs=None, default_hyperparameters=None, retry_config=None, client_config=None, content_policy=None)
Bases: BaseDMInvoker
[BETA] Invoke AnyJev in-process against an OpenAI-compatible vLLM server.
AnyJev owns question rendering, label readout, permutation marginalization, and calibration. This adapter only translates the SDK schemas and runs AnyJev's synchronous decider off the event loop for direct calls to an OpenAI-compatible vLLM server without a gateway service.
Supported features
- Structured state input accepted by AnyJev's state renderer.
- Noul, Choice, and Score questions.
- Retry and timeout handling through the shared invoker policy.
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
Provider-qualified model ID. |
model_provider |
str
|
Provider name used for the transport. |
model_name |
str
|
Provider-local model name. |
default_config |
dict[str, Any]
|
Default arguments passed to |
retry_config |
RetryConfig
|
Retry and timeout configuration for provider calls. |
client_config |
ClientConfig
|
Client lifecycle and ownership configuration. |
content_policy |
ContentPolicy | None
|
Content constraints applied to the state and question text. |
Initialize an embedded AnyJev decider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Model name exposed by the vLLM server. |
required |
base_url
|
str
|
Base URL of the OpenAI-compatible vLLM server. |
required |
api_key
|
str | None
|
AnyJev vLLM server API key. Defaults to the |
None
|
model_kwargs
|
dict[str, Any] | None
|
Additional |
None
|
decider_kwargs
|
dict[str, Any] | None
|
Additional |
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default arguments passed to |
None
|
retry_config
|
RetryConfig | dict[str, Any] | None
|
Retry and timeout configuration for provider calls. Defaults to None. |
None
|
client_config
|
ClientConfig | dict[str, Any] | None
|
Client lifecycle settings. AnyJev's backend has no close operation. Defaults to None. |
None
|
content_policy
|
ContentPolicy | dict[str, Any] | None
|
The per-modality content constraint configuration applied to each string leaf of the state and question text. Defaults to None, in which case no content constraints are applied. |
None
|
Raises:
| Type | Description |
|---|---|
InferenceValueError
|
If the API key is missing. |
ImportError
|
If the |
OpenAIDMInvoker(model_name, api_key=None, model_kwargs=None, default_hyperparameters=None, retry_config=None, client_config=None, content_policy=None)
Bases: BaseDMInvoker, PersistentClientMixin
[BETA] A decision model invoker that uses OpenAI's typed Decisions API.
Supported features
- Text, inline image, and structured state input, with mappings serialized as JSON text.
- Noul, Choice, and Score questions.
- Noul criteria folded into predicate instructions, since OpenAI predicate questions have no criteria field.
- Per-question refusals.
- Retry and timeout handling through the shared invoker policy.
- Ephemeral or persistent OpenAI client lifecycle management through
ClientConfig.
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
Provider-qualified model ID. |
model_provider |
str
|
Provider name used for the transport. |
model_name |
str
|
Provider-local model name. |
default_config |
dict[str, Any]
|
Default config for invoking the decision model. |
retry_config |
RetryConfig
|
Retry and timeout configuration for provider calls. |
client_config |
ClientConfig
|
Client lifecycle and ownership configuration. |
content_policy |
ContentPolicy | None
|
Content constraints applied to the state and question text. |
client_kwargs |
dict[str, Any]
|
Keyword arguments for the OpenAI SDK client. |
Initialize the beta OpenAI decision model invoker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
OpenAI decision model name. |
required |
api_key
|
str | None
|
OpenAI API key. Defaults to the |
None
|
model_kwargs
|
dict[str, Any] | None
|
Additional |
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default request options. Defaults to None. |
None
|
retry_config
|
RetryConfig | dict[str, Any] | None
|
Shared retry and timeout settings. Defaults to None. |
None
|
client_config
|
ClientConfig | dict[str, Any] | None
|
OpenAI client lifecycle settings. Defaults to None. |
None
|
content_policy
|
ContentPolicy | dict[str, Any] | None
|
The per-modality content constraint configuration applied to each string leaf of the state and question text. Defaults to None, in which case no content constraints are applied. |
None
|
OpenRouterDMInvoker(model_name, api_key=None, provider=None, default_hyperparameters=None, retry_config=None, client_config=None, model_kwargs=None, content_policy=None, state_format=OpenRouterStateFormat.NATIVE)
Bases: TypeSafeDMInvoker
[BETA] A decision model invoker to interact with OpenRouter API.
This invoker reaches OpenRouter decision models through OpenRouter's System One API. It extends
TypeSafeDMInvoker with OpenRouter authentication and provider routing preferences.
Supported features
- Structured state input. Supported modalities: a. Text b. Image
- Noul, Choice, Score, and Box questions. Supported modalities: a. Text b. Image
- Native or flattened state serialization through
state_format. - OpenRouter provider routing preferences.
- Retry and timeout handling through the shared invoker policy.
- Ephemeral or persistent client lifecycle management through
ClientConfig.
Examples:
dm_invoker = OpenRouterDMInvoker(
model_name="typesafe/jev-1.14",
api_key="<OPENROUTER_API_KEY>",
provider=["typesafe"],
)
result = await dm_invoker.invoke(
state="A customer requests a refund.",
questions={"refund": DMQuestion.noul(instructions="Is a refund requested?")},
)
Use flat state formatting for models that only read images from the top-level state array:
dm_invoker = OpenRouterDMInvoker(..., state_format="flat")
result = await dm_invoker.invoke(
state={"photo": attachment, "note": "Inspect this listing."},
questions={"matches": DMQuestion.noul(instructions="Does the photo match the note?")},
)
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
Provider-qualified model ID. |
model_provider |
str
|
Provider name used for the transport. |
model_name |
str
|
Provider-local model name. |
default_config |
dict[str, Any]
|
Default config for invoking the decision model. |
retry_config |
RetryConfig
|
Retry and timeout configuration for provider calls. |
client_config |
ClientConfig
|
Client lifecycle and ownership configuration. |
content_policy |
ContentPolicy | None
|
Content constraints applied to the state and question text. |
client_kwargs |
dict[str, Any]
|
Keyword arguments for the TypeSafe SDK client. |
provider_config |
dict[str, Any] | None
|
OpenRouter provider routing preferences. |
state_format |
OpenRouterStateFormat
|
How decision state is serialized for OpenRouter. |
Initialize the beta OpenRouter decision model invoker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
TypeSafe decision model name available through OpenRouter. |
required |
api_key
|
str | None
|
OpenRouter API key. Defaults to the |
None
|
provider
|
str | list[str] | dict[str, Any] | None
|
OpenRouter provider routing preferences.
A provider name or list becomes an |
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default request options for each invocation. Defaults to None. |
None
|
retry_config
|
RetryConfig | dict[str, Any] | None
|
Shared retry and timeout configuration. Defaults to None. |
None
|
client_config
|
ClientConfig | dict[str, Any] | None
|
Client lifecycle and ownership settings. Defaults to None, which creates a client for each invocation. |
None
|
model_kwargs
|
dict[str, Any] | None
|
Additional TypeSafe client parameters, e.g. |
None
|
content_policy
|
ContentPolicy | dict[str, Any] | None
|
The per-modality content constraint configuration applied to each string leaf of the state and question text. Defaults to None, in which case no content constraints are applied. |
None
|
state_format
|
OpenRouterStateFormat | str
|
How decision state is serialized. |
NATIVE
|
Raises:
| Type | Description |
|---|---|
InferenceValueError
|
If the API key is missing. |
CoreValueError
|
If the state format is unsupported. |
PerplexityDMInvoker(model_name, api_key=None, default_hyperparameters=None, retry_config=None, client_config=None, model_kwargs=None, content_policy=None)
Bases: BaseDMInvoker, PersistentClientMixin
[BETA] A decision model invoker to interact with the Perplexity Decisions API.
Supported features
- Structured state input, including inline image attachments.
- Noul, Choice, and Score questions.
- Retry and timeout handling through the shared invoker policy.
- Ephemeral or persistent client lifecycle management through
ClientConfig.
Examples:
dm_invoker = PerplexityDMInvoker(model_name="pplx-decider-v1-27b", api_key="<PERPLEXITY_API_KEY>")
result = await dm_invoker.invoke(
state="A customer requests a refund.",
questions={"refund": DMQuestion.noul(instructions="Is a refund requested?")},
)
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
Provider-qualified model ID. |
model_provider |
str
|
Provider name used for the transport. |
model_name |
str
|
Provider-local model name. |
default_config |
dict[str, Any]
|
Default config for invoking the decision model. |
retry_config |
RetryConfig
|
Retry and timeout configuration for provider calls. |
client_config |
ClientConfig
|
Client lifecycle and ownership configuration. |
content_policy |
ContentPolicy | None
|
Content constraints applied to the state and question text. |
client_kwargs |
dict[str, Any]
|
Keyword arguments for the HTTP client. |
Initialize the beta Perplexity decision model invoker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
Perplexity decision model name, e.g. |
required |
api_key
|
str | None
|
Perplexity API key. Defaults to the |
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default request body fields for each invocation. Defaults to None. |
None
|
retry_config
|
RetryConfig | dict[str, Any] | None
|
Shared retry and timeout configuration. Defaults to None. |
None
|
client_config
|
ClientConfig | dict[str, Any] | None
|
Client lifecycle and ownership settings. Defaults to None, which creates a client for each invocation. |
None
|
model_kwargs
|
dict[str, Any] | None
|
Additional |
None
|
content_policy
|
ContentPolicy | dict[str, Any] | None
|
The per-modality content constraint configuration applied to each string leaf of the state and question text. Defaults to None, in which case no content constraints are applied. |
None
|
Raises:
| Type | Description |
|---|---|
InferenceValueError
|
If the API key is missing. |
TypeSafeDMInvoker(model_name, api_key=None, default_hyperparameters=None, retry_config=None, client_config=None, model_kwargs=None, content_policy=None)
Bases: BaseDMInvoker, PersistentClientMixin
[BETA] A decision model invoker to interact with the TypeSafe API directly.
Supported features
- Structured state input. Supported modalities: a. Text b. Image
- Noul, Choice, Score, and Box questions. Supported modalities: a. Text b. Image
- Retry and timeout handling through the shared invoker policy.
- Ephemeral or persistent client lifecycle management through
ClientConfig.
Examples:
dm_invoker = TypeSafeDMInvoker(model_name="jev-latest", api_key="<TYPESAFE_API_KEY>")
result = await dm_invoker.invoke(
state="A customer requests a refund.",
questions={"refund": DMQuestion.noul(instructions="Is a refund requested?")},
)
Attributes:
| Name | Type | Description |
|---|---|---|
model_id |
str
|
Provider-qualified model ID. |
model_provider |
str
|
Provider name used for the transport. |
model_name |
str
|
Provider-local model name. |
default_config |
dict[str, Any]
|
Default config for invoking the decision model. |
retry_config |
RetryConfig
|
Retry and timeout configuration for provider calls. |
client_config |
ClientConfig
|
Client lifecycle and ownership configuration. |
content_policy |
ContentPolicy | None
|
Content constraints applied to the state and question text. |
client_kwargs |
dict[str, Any]
|
Keyword arguments for the TypeSafe SDK client. |
Initialize the beta TypeSafe decision model invoker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_name
|
str
|
TypeSafe decision model name, e.g. |
required |
api_key
|
str | None
|
TypeSafe API key. Defaults to the |
None
|
default_hyperparameters
|
dict[str, Any] | None
|
Default request options for each invocation. Defaults to None. |
None
|
retry_config
|
RetryConfig | dict[str, Any] | None
|
Shared retry and timeout configuration. Defaults to None. |
None
|
client_config
|
ClientConfig | dict[str, Any] | None
|
Client lifecycle and ownership settings. Defaults to None, which creates a client for each invocation. |
None
|
model_kwargs
|
dict[str, Any] | None
|
Additional TypeSafe client parameters, e.g. |
None
|
content_policy
|
ContentPolicy | dict[str, Any] | None
|
The per-modality content constraint configuration applied to each string leaf of the state and question text. Defaults to None, in which case no content constraints are applied. |
None
|
Raises:
| Type | Description |
|---|---|
InferenceValueError
|
If the API key is missing. |