MCPcopy Create free account
hub / github.com/evilsocket/cake / list_models

Function list_models

cake-core/src/utils/models.rs:70–95  ·  view source on GitHub ↗

Scan all known locations for models and return a list of discovered models.

()

Source from the content-addressed store, hash-verified

68
69/// Scan all known locations for models and return a list of discovered models.
70pub fn list_models() -> Result<Vec<LocalModel>> {
71 let mut models = Vec::new();
72
73 // 1. Scan HuggingFace cache
74 if let Some(hf_cache) = hf_cache_dir() {
75 scan_hf_cache(&hf_cache, &mut models)?;
76 }
77
78 // 2. Scan zero-config cluster cache
79 if let Some(cake_cache) = cake_cache_dir() {
80 scan_cake_cache(&cake_cache, &mut models)?;
81 }
82
83 // Sort: complete first, then by name
84 models.sort_by(|a, b| {
85 let status_ord = |s: &ModelStatus| match s {
86 ModelStatus::Complete => 0,
87 ModelStatus::Partial { .. } => 1,
88 };
89 status_ord(&a.status)
90 .cmp(&status_ord(&b.status))
91 .then_with(|| a.name.cmp(&b.name))
92 });
93
94 Ok(models)
95}
96
97/// Find a model by name. Supports exact match (`org/model`) or suffix match (`model`).
98/// Returns `Err` if the suffix match is ambiguous (multiple models match).

Callers 3

find_modelFunction · 0.70
mainFunction · 0.50

Calls 4

scan_hf_cacheFunction · 0.85
cake_cache_dirFunction · 0.85
scan_cake_cacheFunction · 0.85
hf_cache_dirFunction · 0.70

Tested by 1