mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
cleanup
This commit is contained in:
@@ -10,9 +10,6 @@ const NANOGPT_PROVIDER: &str = "nano-gpt";
|
||||
pub struct NanoGptLoader;
|
||||
|
||||
/// Fetch canonical models fresh from the NanoGPT API.
|
||||
///
|
||||
/// This is the same loader used by `build_canonical_models`, but can be
|
||||
/// called directly at runtime for fresher data.
|
||||
pub async fn load_models() -> Result<Vec<CanonicalModel>> {
|
||||
NanoGptLoader.load_models().await
|
||||
}
|
||||
@@ -71,7 +68,6 @@ fn convert_model(model: NanoGptModel) -> CanonicalModel {
|
||||
let caps = model.capabilities.unwrap_or_default();
|
||||
let pricing = model.pricing.unwrap_or_default();
|
||||
|
||||
// Build input modalities
|
||||
let mut input_modalities = vec![Modality::Text];
|
||||
if caps.vision {
|
||||
input_modalities.push(Modality::Image);
|
||||
@@ -145,76 +141,4 @@ impl CanonicalModelLoader for NanoGptLoader {
|
||||
|
||||
Ok(models)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_convert_model_full() {
|
||||
let model = NanoGptModel {
|
||||
id: "claude-sonnet-4-5-20250929".to_string(),
|
||||
name: Some("Claude Sonnet 4.5".to_string()),
|
||||
owned_by: Some("anthropic".to_string()),
|
||||
context_length: Some(1_000_000),
|
||||
max_output_tokens: Some(64_000),
|
||||
capabilities: Some(NanoGptCapabilities {
|
||||
vision: true,
|
||||
reasoning: false,
|
||||
tool_calling: true,
|
||||
pdf_upload: true,
|
||||
}),
|
||||
pricing: Some(NanoGptPricing {
|
||||
prompt: Some(2.992),
|
||||
completion: Some(14.994),
|
||||
}),
|
||||
created: Some(1759104000),
|
||||
};
|
||||
|
||||
let canonical = convert_model(model);
|
||||
|
||||
assert_eq!(canonical.id, "nano-gpt/claude-sonnet-4-5-20250929");
|
||||
assert_eq!(canonical.name, "Claude Sonnet 4.5");
|
||||
assert_eq!(canonical.family, Some("anthropic".to_string()));
|
||||
assert_eq!(canonical.limit.context, 1_000_000);
|
||||
assert_eq!(canonical.limit.output, Some(64_000));
|
||||
assert!(canonical.tool_call);
|
||||
assert_eq!(canonical.reasoning, Some(false));
|
||||
assert_eq!(canonical.cost.input, Some(2.992));
|
||||
assert_eq!(canonical.cost.output, Some(14.994));
|
||||
assert!(canonical.modalities.input.contains(&Modality::Text));
|
||||
assert!(canonical.modalities.input.contains(&Modality::Image));
|
||||
assert!(canonical.modalities.input.contains(&Modality::Pdf));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_convert_model_minimal() {
|
||||
let model = NanoGptModel {
|
||||
id: "auto-model".to_string(),
|
||||
name: Some("Auto model".to_string()),
|
||||
owned_by: None,
|
||||
context_length: None,
|
||||
max_output_tokens: None,
|
||||
capabilities: None,
|
||||
pricing: None,
|
||||
created: None,
|
||||
};
|
||||
|
||||
let canonical = convert_model(model);
|
||||
|
||||
assert_eq!(canonical.id, "nano-gpt/auto-model");
|
||||
assert_eq!(canonical.name, "Auto model");
|
||||
assert_eq!(canonical.family, None);
|
||||
assert_eq!(canonical.limit.context, 128_000); // default
|
||||
assert_eq!(canonical.limit.output, None);
|
||||
assert!(!canonical.tool_call);
|
||||
assert_eq!(canonical.cost.input, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_timestamp_to_date() {
|
||||
assert_eq!(timestamp_to_date(1759104000), "2025-09-29");
|
||||
assert_eq!(timestamp_to_date(0), "1970-01-01");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user