|
| 1 | +use super::{BucketRange, Experiment, Layer}; |
| 2 | +use lazy_static::lazy_static; |
| 3 | +use std::collections::HashMap; |
| 4 | +use std::str::FromStr; |
| 5 | +use warpui::AppContext; |
| 6 | + |
| 7 | +lazy_static! { |
| 8 | + pub static ref FREE_TIER_DEFAULT_MODEL_LAYER: Layer = Layer { |
| 9 | + name: "FreeTierDefaultModelLayer", |
| 10 | + hasher_seeds: (3141, 5926), |
| 11 | + traffic_allocations: HashMap::from([ |
| 12 | + (FreeTierDefaultModel::AutoEfficient.get_group_id(), 50.0), |
| 13 | + (FreeTierDefaultModel::AutoOpen.get_group_id(), 50.0), |
| 14 | + ]), |
| 15 | + bucket_ranges: vec![ |
| 16 | + BucketRange::new(FreeTierDefaultModel::AutoEfficient, 0..500), |
| 17 | + BucketRange::new(FreeTierDefaultModel::AutoOpen, 500..1000), |
| 18 | + ] |
| 19 | + }; |
| 20 | +} |
| 21 | + |
| 22 | +/// 50/50 A/B test of the default model surfaced to free-tier users in the |
| 23 | +/// pre-signup onboarding ("configure oz") model picker. |
| 24 | +#[derive(Debug)] |
| 25 | +pub enum FreeTierDefaultModel { |
| 26 | + /// Control: keep the existing free-tier default (auto (cost-efficient)). |
| 27 | + AutoEfficient, |
| 28 | + /// Experiment: surface auto (open-weights) as the default for free users. |
| 29 | + AutoOpen, |
| 30 | +} |
| 31 | + |
| 32 | +const FREE_TIER_DEFAULT_MODEL_AUTO_EFFICIENT: &str = "AutoEfficient"; |
| 33 | +const FREE_TIER_DEFAULT_MODEL_AUTO_OPEN: &str = "AutoOpen"; |
| 34 | + |
| 35 | +impl Experiment<FreeTierDefaultModel> for FreeTierDefaultModel { |
| 36 | + fn name() -> &'static str { |
| 37 | + "FreeTierDefaultModel" |
| 38 | + } |
| 39 | + |
| 40 | + fn variant(&self) -> &'static str { |
| 41 | + match self { |
| 42 | + Self::AutoEfficient => FREE_TIER_DEFAULT_MODEL_AUTO_EFFICIENT, |
| 43 | + Self::AutoOpen => FREE_TIER_DEFAULT_MODEL_AUTO_OPEN, |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + fn allow_user_overrides_in_stable() -> bool { |
| 48 | + false |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +impl FromStr for FreeTierDefaultModel { |
| 53 | + type Err = anyhow::Error; |
| 54 | + |
| 55 | + fn from_str(s: &str) -> Result<Self, Self::Err> { |
| 56 | + match s { |
| 57 | + FREE_TIER_DEFAULT_MODEL_AUTO_EFFICIENT => Ok(Self::AutoEfficient), |
| 58 | + FREE_TIER_DEFAULT_MODEL_AUTO_OPEN => Ok(Self::AutoOpen), |
| 59 | + _ => Err(anyhow::anyhow!( |
| 60 | + "Variant {} is not a valid group in FreeTierDefaultModel", |
| 61 | + s |
| 62 | + )), |
| 63 | + } |
| 64 | + } |
| 65 | +} |
| 66 | + |
| 67 | +impl FreeTierDefaultModel { |
| 68 | + pub fn should_default_to_auto_open(ctx: &mut AppContext) -> bool { |
| 69 | + matches!(Self::get_group(ctx), Some(Self::AutoOpen)) |
| 70 | + } |
| 71 | +} |
0 commit comments