pub trait ToolSelector:
Send
+ Sync
+ 'static {
// Required method
fn select<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
available: &'life1 [ToolSchema],
messages: &'life2 [Message],
) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Async trait for selecting which tools to present to the LLM.
Implementations receive the full set of available tools and the conversation history, then return the names of tools to include.
§Examples
use pe_tools::selector::{ToolSelector, AllToolsSelector};
use pe_core::{ToolSchema, Message};
let selector = AllToolsSelector;
let tools = vec![
ToolSchema {
name: "search".into(),
description: "Search the web".into(),
parameters: serde_json::json!({}),
strict: false,
},
];
let selected = selector.select(&tools, &[]).await;
assert_eq!(selected, vec!["search".to_string()]);Required Methods§
Sourcefn select<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
available: &'life1 [ToolSchema],
messages: &'life2 [Message],
) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn select<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
available: &'life1 [ToolSchema],
messages: &'life2 [Message],
) -> Pin<Box<dyn Future<Output = Vec<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Select tool names from the available set.
Returns a Vec<String> of tool names that should be included
in the next LLM call. Names must match ToolSchema::name values.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".