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

Function detect_text_model_arch

cake-core/src/models/common/config.rs:176–191  ·  view source on GitHub ↗

Auto-detect text model architecture from config.json's "architectures" field.

(config_path: &std::path::Path)

Source from the content-addressed store, hash-verified

174
175/// Auto-detect text model architecture from config.json's "architectures" field.
176pub fn detect_text_model_arch(config_path: &std::path::Path) -> Result<String> {
177 let data = std::fs::read(config_path)
178 .map_err(|e| anyhow!("can't read {}: {:?}", config_path.display(), e))?;
179 let json: serde_json::Value = serde_json::from_slice(&data)
180 .map_err(|e| anyhow!("can't parse {}: {:?}", config_path.display(), e))?;
181
182 if let Some(archs) = json.get("architectures").and_then(|v| v.as_array()) {
183 for arch in archs {
184 if let Some(s) = arch.as_str() {
185 return Ok(s.to_string());
186 }
187 }
188 }
189
190 Ok(String::new())
191}
192
193#[cfg(test)]
194mod tests {

Callers 2

from_argsMethod · 0.85

Calls 1

getMethod · 0.45

Tested by 1