assistant2: Allow profiles to manage context server tools (#27452)
This PR updates the agent profiles with support for managing context server tools. Release Notes: - N/A
This commit is contained in:
parent
aab02a4166
commit
5953c6167b
3 changed files with 34 additions and 4 deletions
|
@ -50,7 +50,8 @@ impl ToolSelector {
|
||||||
menu = menu.toggleable_entry(profile.name.clone(), false, icon_position, None, {
|
menu = menu.toggleable_entry(profile.name.clone(), false, icon_position, None, {
|
||||||
let tools = tool_set.clone();
|
let tools = tool_set.clone();
|
||||||
move |_window, cx| {
|
move |_window, cx| {
|
||||||
tools.disable_source(ToolSource::Native, cx);
|
tools.disable_all_tools(cx);
|
||||||
|
|
||||||
tools.enable(
|
tools.enable(
|
||||||
ToolSource::Native,
|
ToolSource::Native,
|
||||||
&profile
|
&profile
|
||||||
|
@ -59,6 +60,19 @@ impl ToolSelector {
|
||||||
.filter_map(|(tool, enabled)| enabled.then(|| tool.clone()))
|
.filter_map(|(tool, enabled)| enabled.then(|| tool.clone()))
|
||||||
.collect::<Vec<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
for (context_server_id, preset) in &profile.context_servers {
|
||||||
|
tools.enable(
|
||||||
|
ToolSource::ContextServer {
|
||||||
|
id: context_server_id.clone().into(),
|
||||||
|
},
|
||||||
|
&preset
|
||||||
|
.tools
|
||||||
|
.iter()
|
||||||
|
.filter_map(|(tool, enabled)| enabled.then(|| tool.clone()))
|
||||||
|
.collect::<Vec<_>>(),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,10 @@ pub struct AgentProfile {
|
||||||
/// The name of the profile.
|
/// The name of the profile.
|
||||||
pub name: SharedString,
|
pub name: SharedString,
|
||||||
pub tools: IndexMap<Arc<str>, bool>,
|
pub tools: IndexMap<Arc<str>, bool>,
|
||||||
#[allow(dead_code)]
|
|
||||||
pub context_servers: IndexMap<Arc<str>, ContextServerPreset>,
|
pub context_servers: IndexMap<Arc<str>, ContextServerPreset>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ContextServerPreset {
|
pub struct ContextServerPreset {
|
||||||
#[allow(dead_code)]
|
|
||||||
pub tools: IndexMap<Arc<str>, bool>,
|
pub tools: IndexMap<Arc<str>, bool>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -412,6 +412,13 @@ impl Default for LanguageModelSelection {
|
||||||
pub struct AgentProfileContent {
|
pub struct AgentProfileContent {
|
||||||
pub name: Arc<str>,
|
pub name: Arc<str>,
|
||||||
pub tools: IndexMap<Arc<str>, bool>,
|
pub tools: IndexMap<Arc<str>, bool>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub context_servers: IndexMap<Arc<str>, ContextServerPresetContent>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, JsonSchema)]
|
||||||
|
pub struct ContextServerPresetContent {
|
||||||
|
pub tools: IndexMap<Arc<str>, bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
|
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
|
||||||
|
@ -522,7 +529,18 @@ impl Settings for AssistantSettings {
|
||||||
AgentProfile {
|
AgentProfile {
|
||||||
name: profile.name.into(),
|
name: profile.name.into(),
|
||||||
tools: profile.tools,
|
tools: profile.tools,
|
||||||
context_servers: IndexMap::default(),
|
context_servers: profile
|
||||||
|
.context_servers
|
||||||
|
.into_iter()
|
||||||
|
.map(|(context_server_id, preset)| {
|
||||||
|
(
|
||||||
|
context_server_id,
|
||||||
|
ContextServerPreset {
|
||||||
|
tools: preset.tools.clone(),
|
||||||
|
},
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.collect(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue