mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-06 02:48:25 +00:00
fabro-types no longer re-exports the lithos catalog and request types (ProviderId, ModelId, ModelHandle, Message, ContentPart, TokenCounts, Cost, Speed, ReasoningEffort, ReasoningOutput, and the rest). Every crate that uses them depends on lithos-llm and names them there, and the fabro-api progenitor replacements point at the lithos paths. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
47 lines
1.3 KiB
Rust
47 lines
1.3 KiB
Rust
use std::any::{TypeId, type_name};
|
|
|
|
use fabro_api::types::{CompletionCost as ApiCost, CostSource as ApiCostSource};
|
|
use lithos_llm::types::{Cost, CostSource};
|
|
use serde_json::json;
|
|
|
|
#[test]
|
|
fn cost_types_reuse_lithos_types() {
|
|
assert_same_type::<ApiCostSource, CostSource>();
|
|
assert_same_type::<ApiCost, Cost>();
|
|
}
|
|
|
|
#[test]
|
|
fn cost_source_json_matches_openapi_shape() {
|
|
for (source, wire) in [
|
|
(CostSource::Catalog, "catalog"),
|
|
(CostSource::Provider, "provider"),
|
|
(CostSource::Application, "application"),
|
|
] {
|
|
assert_eq!(serde_json::to_value(source).unwrap(), json!(wire));
|
|
assert_eq!(
|
|
serde_json::from_value::<ApiCostSource>(json!(wire)).unwrap(),
|
|
source
|
|
);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn cost_json_matches_openapi_shape() {
|
|
let cost = Cost {
|
|
usd_micros: 125_000,
|
|
source: CostSource::Provider,
|
|
};
|
|
let json = serde_json::to_value(cost).unwrap();
|
|
assert_eq!(json, json!({"usd_micros": 125000, "source": "provider"}));
|
|
assert_eq!(serde_json::from_value::<ApiCost>(json).unwrap(), cost);
|
|
}
|
|
|
|
fn assert_same_type<T: 'static, U: 'static>() {
|
|
assert_eq!(
|
|
TypeId::of::<T>(),
|
|
TypeId::of::<U>(),
|
|
"{} should be the same type as {}",
|
|
type_name::<T>(),
|
|
type_name::<U>()
|
|
);
|
|
}
|