refactor ai serving modules and crates

This commit is contained in:
fawney19
2026-05-02 13:23:54 +08:00
parent 4fc7cecf30
commit c130d0e2c9
309 changed files with 21549 additions and 14265 deletions

View File

@@ -4,7 +4,10 @@ use aether_data_contracts::repository::provider_catalog::StoredProviderCatalogPr
use aether_data_contracts::repository::quota::StoredProviderQuotaSnapshot;
use aether_wallet::{ProviderBillingType, ProviderQuotaSnapshot};
pub fn should_skip_provider_quota(quota: &StoredProviderQuotaSnapshot, now_unix_secs: u64) -> bool {
pub fn should_skip_provider_quota(
quota: &StoredProviderQuotaSnapshot,
_now_unix_secs: u64,
) -> bool {
let snapshot = ProviderQuotaSnapshot {
provider_id: quota.provider_id.clone(),
billing_type: ProviderBillingType::parse(&quota.billing_type),
@@ -16,10 +19,6 @@ pub fn should_skip_provider_quota(quota: &StoredProviderQuotaSnapshot, now_unix_
is_active: quota.is_active,
};
if !snapshot.is_active || snapshot.is_expired(now_unix_secs) {
return true;
}
match snapshot.billing_type {
ProviderBillingType::MonthlyQuota | ProviderBillingType::FreeTier => snapshot
.remaining_quota_usd()
@@ -71,7 +70,7 @@ mod tests {
}
#[test]
fn skips_inactive_or_exhausted_monthly_quota_provider() {
fn skips_only_exhausted_monthly_quota_provider() {
let inactive = StoredProviderQuotaSnapshot::new(
"provider-1".to_string(),
"monthly_quota".to_string(),
@@ -83,7 +82,20 @@ mod tests {
false,
)
.expect("quota should build");
assert!(should_skip_provider_quota(&inactive, 2_000));
assert!(!should_skip_provider_quota(&inactive, 2_000));
let expired = StoredProviderQuotaSnapshot::new(
"provider-1".to_string(),
"monthly_quota".to_string(),
Some(10.0),
1.0,
Some(30),
Some(1_000),
Some(1_500),
true,
)
.expect("quota should build");
assert!(!should_skip_provider_quota(&expired, 2_000));
let exhausted = StoredProviderQuotaSnapshot::new(
"provider-1".to_string(),