Skip to main content

normalize_model_name

Function normalize_model_name 

Source
pub fn normalize_model_name(name: &str) -> String
Expand description

Normalizes model names by removing provider prefixes and version suffixes.

Removes patterns like:

  • Provider prefixes: bedrock/, openai/.
  • Date suffixes: -20231201, -12345678 (exactly 8 ASCII digits).
  • Version suffixes: -v1.0, -v2.

Optimized to minimize string allocations (a single allocation at the end).

ยงExamples

use vct_core::pricing::normalize_model_name;

assert_eq!(normalize_model_name("claude-3-sonnet-20240229"), "claude-3-sonnet");
assert_eq!(normalize_model_name("gpt-4-v1.0"), "gpt-4");
assert_eq!(normalize_model_name("bedrock/claude-3-opus"), "claude-3-opus");