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
//! The [`ModelMetaProbe`] trait — a one-method contract every backend
//! implements. Returns `Ok(None)` for unknown models so callers can chain
//! probes without paying error-handling tax.
use Future;
use crate::;
/// One-method trait implemented by every metadata source (live HTTP probes,
/// static catalogs, fixtures).
///
/// ## Contract
///
/// - **`Ok(Some(desc))`** — the probe recognises `model` and returns what it
/// knows. Unknown sub-fields stay `None`; absent capabilities mean "I
/// can't confirm this," not "the model lacks it."
/// - **`Ok(None)`** — the probe does not recognise `model`. Callers using
/// [`crate::ChainedProbe`] continue to the next probe.
/// - **`Err(ProbeError)`** — the probe could not even attempt the lookup
/// (transport down, malformed response, auth rejection). Hard failures
/// only — never use `Err` to mean "unknown."
///
/// Implementations must be cheap to clone (typically `Arc`-wrap any shared
/// state internally) so probes can be composed into chains.
///
/// ## Example
///
/// ```
/// use rig_model_meta::{ModelDescriptor, ModelMetaProbe, ProbeError, StubProbe};
///
/// # async fn run() -> Result<(), ProbeError> {
/// let probe = StubProbe::new([(
/// "gpt-4o".to_string(),
/// ModelDescriptor::builder("openai", "gpt-4o")
/// .context_window(128_000)
/// .build(),
/// )]);
/// assert_eq!(probe.describe("gpt-4o").await?.unwrap().context_window, Some(128_000));
/// assert!(probe.describe("unknown-model").await?.is_none());
/// # Ok(())
/// # }
/// ```