fix DO pricing URL, model_providers name validation, cost_metrics demo endpoint

This commit is contained in:
Adil Hafeez 2026-03-27 17:14:18 -07:00
parent bd7afd911e
commit bd335cd8bd
6 changed files with 74 additions and 60 deletions

View file

@ -187,11 +187,15 @@ async fn init_app_state(
}
// Validate that all models referenced in top-level routing_preferences exist in model_providers.
// The CLI renders model_providers with `name` = "openai/gpt-4o" and `model` = "gpt-4o",
// so we accept a match against either field.
if let Some(ref route_prefs) = config.routing_preferences {
let provider_model_names: std::collections::HashSet<&str> = config
.model_providers
.iter()
.flat_map(|p| p.model.as_deref())
.flat_map(|p| {
std::iter::once(p.name.as_str()).chain(p.model.as_deref())
})
.collect();
for pref in route_prefs {
for model in &pref.models {

View file

@ -6,7 +6,7 @@ use common::configuration::{MetricsSource, SelectionPolicy, SelectionPreference}
use tokio::sync::RwLock;
use tracing::{info, warn};
const DO_PRICING_URL: &str = "https://api.digitalocean.com/v2/gen-ai/models";
const DO_PRICING_URL: &str = "https://api.digitalocean.com/v2/gen-ai/models/catalog";
pub struct ModelMetricsService {
cost: Arc<RwLock<HashMap<String, f64>>>,

View file

@ -147,6 +147,7 @@ pub enum MetricsSource {
query: String,
refresh_interval: Option<u64>,
},
#[serde(rename = "digitalocean_pricing")]
DigitalOceanPricing {
refresh_interval: Option<u64>,
},