mirror of
https://github.com/tinyhumansai/openhuman.git
synced 2026-07-27 21:08:00 +00:00
feat(cost): LLM pricing + context-window catalog, pre-fills model registry (#4124)
This commit is contained in:
@@ -2968,6 +2968,64 @@ async fn config_controller_mutations_round_trip_over_json_rpc() {
|
||||
"client config must not echo local API keys: {client_payload}"
|
||||
);
|
||||
|
||||
// The model registry is seeded + price/context-window-enriched from the
|
||||
// static pricing catalog on load (in-memory), so a fresh workspace surfaces
|
||||
// real numbers over RPC. Validates the full path: catalog → seed-on-load →
|
||||
// client_config_json → JSON-RPC. (The earlier update_model_settings call did
|
||||
// not include `model_registry`, so the seeded registry is left intact.)
|
||||
let registry = client_payload
|
||||
.get("model_registry")
|
||||
.and_then(Value::as_array)
|
||||
.expect("client config should expose model_registry");
|
||||
assert!(
|
||||
!registry.is_empty(),
|
||||
"model_registry should be auto-seeded from the pricing catalog: {client_payload}"
|
||||
);
|
||||
let opus = registry
|
||||
.iter()
|
||||
.find(|m| m.get("id").and_then(Value::as_str) == Some("claude-opus-4-8"))
|
||||
.unwrap_or_else(|| panic!("seeded registry should contain claude-opus-4-8: {registry:?}"));
|
||||
assert_eq!(
|
||||
opus.get("provider").and_then(Value::as_str),
|
||||
Some("anthropic")
|
||||
);
|
||||
assert_eq!(
|
||||
opus.get("cost_per_1m_input").and_then(Value::as_f64),
|
||||
Some(5.0),
|
||||
"input price should be pre-filled from the catalog: {opus:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
opus.get("cost_per_1m_output").and_then(Value::as_f64),
|
||||
Some(25.0),
|
||||
"output price should be pre-filled from the catalog: {opus:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
opus.get("context_window").and_then(Value::as_u64),
|
||||
Some(1_000_000),
|
||||
"context window should be pre-filled from the catalog: {opus:?}"
|
||||
);
|
||||
// Every seeded entry carries non-zero pricing + context window — the whole
|
||||
// point of the catalog pre-fill.
|
||||
for entry in registry {
|
||||
let id = entry.get("id").and_then(Value::as_str).unwrap_or("<none>");
|
||||
assert!(
|
||||
entry
|
||||
.get("cost_per_1m_output")
|
||||
.and_then(Value::as_f64)
|
||||
.unwrap_or(0.0)
|
||||
> 0.0,
|
||||
"{id} missing output price: {entry:?}"
|
||||
);
|
||||
assert!(
|
||||
entry
|
||||
.get("context_window")
|
||||
.and_then(Value::as_u64)
|
||||
.unwrap_or(0)
|
||||
> 0,
|
||||
"{id} missing context window: {entry:?}"
|
||||
);
|
||||
}
|
||||
|
||||
let memory = rpc(
|
||||
&harness.rpc_base,
|
||||
10_004,
|
||||
|
||||
Reference in New Issue
Block a user