chore: initial clean commit
This commit is contained in:
24
src/utils/registry.rs
Normal file
24
src/utils/registry.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use anyhow::Result;
|
||||
use tracing::info;
|
||||
use crate::models::registry::ModelRegistry;
|
||||
|
||||
const MODELS_DEV_URL: &str = "https://models.dev/api.json";
|
||||
|
||||
pub async fn fetch_registry() -> Result<ModelRegistry> {
|
||||
info!("Fetching model registry from {}", MODELS_DEV_URL);
|
||||
|
||||
let client = reqwest::Client::builder()
|
||||
.timeout(std::time::Duration::from_secs(10))
|
||||
.build()?;
|
||||
|
||||
let response = client.get(MODELS_DEV_URL).send().await?;
|
||||
|
||||
if !response.status().is_success() {
|
||||
return Err(anyhow::anyhow!("Failed to fetch registry: HTTP {}", response.status()));
|
||||
}
|
||||
|
||||
let registry: ModelRegistry = response.json().await?;
|
||||
info!("Successfully loaded model registry");
|
||||
|
||||
Ok(registry)
|
||||
}
|
||||
Reference in New Issue
Block a user