1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Traits for models.dev integration.
//!
//! This module defines the ModelsDevAware trait for integrating
//! with the models.dev API schema.
use crate;
/// A trait for types that can be integrated with models.dev provider information.
///
/// This trait allows provider implementations to declare their compatibility with
/// models.dev schema and convert from models.dev provider information.
///
/// # Example
///
/// ```rust
/// use models_dev::traits::ModelsDevAware;
/// use models_dev::types::{Provider, Model};
///
/// struct MyProvider {
/// // Provider-specific fields
/// }
///
/// impl ModelsDevAware for MyProvider {
/// fn supported_npm_packages() -> Vec<String> {
/// vec!["@ai-sdk/my-provider".to_string()]
/// }
///
/// fn from_models_dev_info(provider: &Provider, model: Option<&Model>) -> Option<Self> {
/// // Check if this provider supports the NPM package
/// if !Self::supported_npm_packages().contains(&provider.npm) {
/// return None;
/// }
///
/// // Create provider instance from models.dev info
/// Some(MyProvider {
/// // Initialize with provider and model data
/// })
/// }
/// }
/// ```