Tool Selector
Select relevant regular tools before language-model invocation.
DMToolSelector(dm_invoker, threshold=_DEFAULT_THRESHOLD, relevance_question=None)
Bases: BaseToolSelector
[BETA] Select regular tools using one binary relevance question per candidate.
The complete candidate catalog is sent in one decisions-model request. Selection is a filtering optimization only; callers must authorize candidate tools before invoking this selector.
Examples:
dm_invoker = build_dm_invoker(...)
tool_selector = DMToolSelector(dm_invoker)
selected_tools = await tool_selector.select(messages=messages, tools=tools)
Attributes:
| Name | Type | Description |
|---|---|---|
dm_invoker |
BaseDMInvoker
|
The injected decisions-model invoker. |
threshold |
float
|
Inclusive probability threshold for retaining a tool. |
relevance_question |
DMQuestion
|
Custom |
Initialize a decisions-model tool selector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dm_invoker
|
BaseDMInvoker
|
The injected decisions-model invoker. |
required |
threshold
|
float
|
Inclusive probability threshold for retaining a tool. Defaults to _DEFAULT_THRESHOLD. |
_DEFAULT_THRESHOLD
|
relevance_question
|
DMQuestion | None
|
Custom |
None
|
Raises:
| Type | Description |
|---|---|
InferenceValueError
|
If threshold is not a finite probability in [0, 1], or relevance_question
is not a |
select(messages, tools, *, max_tools=None)
async
Return candidate tools that the decisions model considers relevant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
list[Message]
|
Complete canonical messages for the LM request. |
required |
tools
|
list[Tool]
|
Already-authorized candidate tools with unique names. |
required |
max_tools
|
int | None
|
Positive cap on selected tools. Highest-probability tools are retained, then returned in original input order. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
list[Tool]
|
list[Tool]: Original selected tools in input order. |