Skip to content

Commit 378cbc3

Browse files
committed
feat: add Chutes provider with TEE-only model restriction
1 parent 334f682 commit 378cbc3

4 files changed

Lines changed: 56 additions & 11 deletions

File tree

src/cortex-common/src/model_presets/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub use types::{ModelAlias, ModelPreset, ModelResolution};
1818
pub use constants::{DEFAULT_MODEL, DEFAULT_MODELS, DEFAULT_PROVIDER};
1919

2020
// Re-export preset data and helpers
21-
pub use presets::{MODEL_PRESETS, get_model_preset, get_models_for_provider};
21+
pub use presets::{MODEL_PRESETS, get_model_preset, get_models_for_provider, validate_chutes_model, provider_allows_custom_models};
2222

2323
// Re-export alias data and helpers
2424
pub use aliases::{MODEL_ALIASES, list_model_aliases, resolve_model_alias};

src/cortex-common/src/model_presets/presets.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,17 @@ pub const MODEL_PRESETS: &[ModelPreset] = &[
806806
supports_tools: true,
807807
supports_reasoning: false,
808808
},
809+
// Chutes TEE models (Trusted Execution Environment)
810+
// Security requirement: Only models with '-TEE' suffix are allowed
811+
ModelPreset {
812+
id: "moonshotai/Kimi-K2.5-TEE",
813+
name: "Kimi K2.5 (TEE)",
814+
provider: "chutes",
815+
context_window: 262_144,
816+
supports_vision: false,
817+
supports_tools: true,
818+
supports_reasoning: true,
819+
},
809820
];
810821

811822
/// Get a model preset by ID.
@@ -820,3 +831,24 @@ pub fn get_models_for_provider(provider: &str) -> Vec<&'static ModelPreset> {
820831
.filter(|m| m.provider == provider)
821832
.collect()
822833
}
834+
835+
/// Validates that a model is allowed for the Chutes provider.
836+
/// Chutes only allows TEE (Trusted Execution Environment) models for security.
837+
/// Returns Ok(()) if valid, Err with message if invalid.
838+
pub fn validate_chutes_model(model: &str) -> Result<(), String> {
839+
if !model.ends_with("-TEE") {
840+
return Err(format!(
841+
"Chutes provider only allows TEE models (models ending with '-TEE'). \
842+
Model '{}' is not a TEE model. Available TEE models: moonshotai/Kimi-K2.5-TEE",
843+
model
844+
));
845+
}
846+
Ok(())
847+
}
848+
849+
/// Checks if a provider restricts custom models.
850+
/// Chutes only allows predefined TEE models, no custom models.
851+
pub fn provider_allows_custom_models(provider: &str) -> bool {
852+
// Chutes does NOT allow custom models - only predefined TEE models
853+
provider != "chutes"
854+
}

src/cortex-tui/src/modal/providers.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ impl ProviderInfo {
7070

7171
/// Returns the list of known providers with their default information.
7272
pub fn known_providers() -> Vec<ProviderInfo> {
73-
vec![ProviderInfo::new("cortex", "Cortex").with_description("Cortex AI Gateway")]
73+
vec![
74+
ProviderInfo::new("cortex", "Cortex").with_description("Cortex AI Gateway"),
75+
ProviderInfo::new("chutes", "Chutes (TEE)").with_description("TEE-secured models only"),
76+
]
7477
}
7578

7679
// ============================================================================
@@ -402,8 +405,9 @@ mod tests {
402405
fn test_known_providers() {
403406
let providers = known_providers();
404407

405-
assert_eq!(providers.len(), 1);
408+
assert_eq!(providers.len(), 2);
406409
assert!(providers.iter().any(|p| p.id == "cortex"));
410+
assert!(providers.iter().any(|p| p.id == "chutes"));
407411
}
408412

409413
#[test]

src/cortex-tui/src/providers/config.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,23 @@ pub const CONFIG_FILE: &str = "config.json";
2727
/// Sessions directory name
2828
pub const SESSIONS_DIR: &str = "sessions";
2929

30-
/// Single provider - Cortex Backend (for compatibility with old code)
31-
pub const PROVIDERS: &[ProviderInfo] = &[ProviderInfo {
32-
id: "cortex",
33-
name: "Cortex",
34-
env_var: "CORTEX_AUTH_TOKEN",
35-
base_url: "https://api.cortex.foundation",
36-
requires_key: true,
37-
}];
30+
/// Supported providers
31+
pub const PROVIDERS: &[ProviderInfo] = &[
32+
ProviderInfo {
33+
id: "cortex",
34+
name: "Cortex",
35+
env_var: "CORTEX_AUTH_TOKEN",
36+
base_url: "https://api.cortex.foundation",
37+
requires_key: true,
38+
},
39+
ProviderInfo {
40+
id: "chutes",
41+
name: "Chutes (TEE)",
42+
env_var: "CHUTES_API_KEY",
43+
base_url: "https://llm.chutes.ai",
44+
requires_key: true,
45+
},
46+
];
3847

3948
// ============================================================
4049
// TYPES

0 commit comments

Comments
 (0)