Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/settings/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -2352,6 +2352,7 @@
"api_url": "https://api.openai.com/v1",
},
"openai_compatible": {},
"anthropic_compatible": {},
"opencode": {
"api_url": "https://opencode.ai/zen",
},
Expand Down
67 changes: 48 additions & 19 deletions crates/agent_ui/src/agent_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,14 @@ impl AgentConfiguration {
let key_to_remove: Arc<str> = Arc::from(provider_id.0.as_ref());
openai_compatible.remove(&key_to_remove);
}
if let Some(ref mut anthropic_compatible) = settings
.language_models
.as_mut()
.and_then(|lm| lm.anthropic_compatible.as_mut())
{
let key_to_remove: Arc<str> = Arc::from(provider_id.0.as_ref());
anthropic_compatible.remove(&key_to_remove);
}
}
});
})
Expand Down Expand Up @@ -445,21 +453,37 @@ impl AgentConfiguration {
let workspace = self.workspace.clone();
move |window, cx| {
Some(ContextMenu::build(window, cx, |menu, _window, _cx| {
menu.header("Compatible APIs").entry("OpenAI", None, {
let workspace = workspace.clone();
move |window, cx| {
workspace
.update(cx, |workspace, cx| {
AddLlmProviderModal::toggle(
LlmCompatibleProvider::OpenAi,
workspace,
window,
cx,
);
})
.log_err();
}
})
menu.header("Compatible APIs")
.entry("OpenAI", None, {
let workspace = workspace.clone();
move |window, cx| {
workspace
.update(cx, |workspace, cx| {
AddLlmProviderModal::toggle(
LlmCompatibleProvider::OpenAi,
workspace,
window,
cx,
);
})
.log_err();
}
})
.entry("Anthropic", None, {
let workspace = workspace.clone();
move |window, cx| {
workspace
.update(cx, |workspace, cx| {
AddLlmProviderModal::toggle(
LlmCompatibleProvider::Anthropic,
workspace,
window,
cx,
);
})
.log_err();
}
})
}))
}
})
Expand Down Expand Up @@ -1509,13 +1533,18 @@ fn find_text_in_buffer(
}
}

// OpenAI-compatible providers are user-configured and can be removed,
// whereas built-in providers (like Anthropic, OpenAI, Google, etc.) can't.
// OpenAI-compatible and Anthropic-compatible providers are user-configured and can be
// removed, whereas built-in providers (like Anthropic, OpenAI, Google, etc.) can't.
//
// If in the future we have more "API-compatible-type" of providers,
// they should be included here as removable providers.
fn is_removable_provider(provider_id: &LanguageModelProviderId, cx: &App) -> bool {
AllLanguageModelSettings::get_global(cx)
let settings = AllLanguageModelSettings::get_global(cx);
let is_openai_compatible = settings
.openai_compatible
.contains_key(provider_id.0.as_ref())
.contains_key(provider_id.0.as_ref());
let is_anthropic_compatible = settings
.anthropic_compatible
.contains_key(provider_id.0.as_ref());
is_openai_compatible || is_anthropic_compatible
}
Loading
Loading