#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct ToolSearch {
threshold: Option<usize>,
never_defer: Vec<String>,
}
impl ToolSearch {
pub fn automatic() -> Self {
Self::default()
}
pub fn threshold(mut self, threshold: usize) -> Self {
self.threshold = Some(threshold);
self
}
pub fn never_defer<I, S>(mut self, names: I) -> Self
where
I: IntoIterator<Item = S>,
S: Into<String>,
{
self.never_defer.extend(names.into_iter().map(Into::into));
self
}
}
impl crate::IntoCapability for ToolSearch {
fn into_capability(self) -> crate::CapabilitySpec {
let mut config = serde_json::Map::new();
if let Some(threshold) = self.threshold {
config.insert("threshold".to_string(), threshold.into());
}
if !self.never_defer.is_empty() {
config.insert("never_defer".to_string(), self.never_defer.into());
}
crate::CapabilityRef::new("auto_tool_search")
.config(serde_json::Value::Object(config))
.into()
}
}