Add feature-flagged access to LLM service (#16136)
This PR adds feature-flagged access to the LLM service. We've repurposed the `language-models` feature flag to be used for providing access to Claude 3.5 Sonnet through the Zed provider. The remaining RPC endpoints that were previously behind the `language-models` feature flag are now behind a staff check. We also put some Zed Pro related messaging behind a feature flag. Release Notes: - N/A --------- Co-authored-by: Max <max@zed.dev>
This commit is contained in:
parent
3bebb8b401
commit
8a148f3a13
2 changed files with 49 additions and 43 deletions
|
@ -8,7 +8,7 @@ use anthropic::AnthropicError;
|
|||
use anyhow::{anyhow, bail, Context as _, Result};
|
||||
use client::{Client, PerformCompletionParams, UserStore, EXPIRED_LLM_TOKEN_HEADER_NAME};
|
||||
use collections::BTreeMap;
|
||||
use feature_flags::{FeatureFlagAppExt, LanguageModels};
|
||||
use feature_flags::{FeatureFlagAppExt, ZedPro};
|
||||
use futures::{future::BoxFuture, stream::BoxStream, AsyncBufReadExt, FutureExt, StreamExt};
|
||||
use gpui::{
|
||||
AnyElement, AnyView, AppContext, AsyncAppContext, FontWeight, Model, ModelContext,
|
||||
|
@ -168,13 +168,7 @@ impl LanguageModelProvider for CloudLanguageModelProvider {
|
|||
fn provided_models(&self, cx: &AppContext) -> Vec<Arc<dyn LanguageModel>> {
|
||||
let mut models = BTreeMap::default();
|
||||
|
||||
let is_user = !cx.has_flag::<LanguageModels>();
|
||||
if is_user {
|
||||
models.insert(
|
||||
anthropic::Model::Claude3_5Sonnet.id().to_string(),
|
||||
CloudModel::Anthropic(anthropic::Model::Claude3_5Sonnet),
|
||||
);
|
||||
} else {
|
||||
if cx.is_staff() {
|
||||
for model in anthropic::Model::iter() {
|
||||
if !matches!(model, anthropic::Model::Custom { .. }) {
|
||||
models.insert(model.id().to_string(), CloudModel::Anthropic(model));
|
||||
|
@ -218,6 +212,11 @@ impl LanguageModelProvider for CloudLanguageModelProvider {
|
|||
};
|
||||
models.insert(model.id().to_string(), model.clone());
|
||||
}
|
||||
} else {
|
||||
models.insert(
|
||||
anthropic::Model::Claude3_5Sonnet.id().to_string(),
|
||||
CloudModel::Anthropic(anthropic::Model::Claude3_5Sonnet),
|
||||
);
|
||||
}
|
||||
|
||||
models
|
||||
|
@ -869,34 +868,39 @@ impl Render for ConfigurationView {
|
|||
if is_pro {
|
||||
"You have full access to Zed's hosted models from Anthropic, OpenAI, Google with faster speeds and higher limits through Zed Pro."
|
||||
} else {
|
||||
"You have basic access to models from Anthropic, OpenAI, Google and more through the Zed AI Free plan."
|
||||
"You have basic access to models from Anthropic through the Zed AI Free plan."
|
||||
}))
|
||||
.child(
|
||||
if is_pro {
|
||||
.children(if is_pro {
|
||||
Some(
|
||||
h_flex().child(
|
||||
Button::new("manage_settings", "Manage Subscription")
|
||||
.style(ButtonStyle::Filled)
|
||||
.on_click(cx.listener(|_, _, cx| {
|
||||
cx.open_url(ACCOUNT_SETTINGS_URL)
|
||||
})))
|
||||
} else {
|
||||
Button::new("manage_settings", "Manage Subscription")
|
||||
.style(ButtonStyle::Filled)
|
||||
.on_click(
|
||||
cx.listener(|_, _, cx| cx.open_url(ACCOUNT_SETTINGS_URL)),
|
||||
),
|
||||
),
|
||||
)
|
||||
} else if cx.has_flag::<ZedPro>() {
|
||||
Some(
|
||||
h_flex()
|
||||
.gap_2()
|
||||
.child(
|
||||
Button::new("learn_more", "Learn more")
|
||||
.style(ButtonStyle::Subtle)
|
||||
.on_click(cx.listener(|_, _, cx| {
|
||||
cx.open_url(ZED_AI_URL)
|
||||
})))
|
||||
Button::new("learn_more", "Learn more")
|
||||
.style(ButtonStyle::Subtle)
|
||||
.on_click(cx.listener(|_, _, cx| cx.open_url(ZED_AI_URL))),
|
||||
)
|
||||
.child(
|
||||
Button::new("upgrade", "Upgrade")
|
||||
.style(ButtonStyle::Subtle)
|
||||
.color(Color::Accent)
|
||||
.on_click(cx.listener(|_, _, cx| {
|
||||
cx.open_url(ACCOUNT_SETTINGS_URL)
|
||||
})))
|
||||
},
|
||||
)
|
||||
Button::new("upgrade", "Upgrade")
|
||||
.style(ButtonStyle::Subtle)
|
||||
.color(Color::Accent)
|
||||
.on_click(
|
||||
cx.listener(|_, _, cx| cx.open_url(ACCOUNT_SETTINGS_URL)),
|
||||
),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
None
|
||||
})
|
||||
} else {
|
||||
v_flex()
|
||||
.gap_6()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue