Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion crates/tinyinference-llm/src/providers/overrides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,23 @@ pub type CatalogListing<Ctx> =
pub type CatalogLimitsFuture = BoxFuture<Option<DiscoveryRequest>>;

/// Input to an async provider catalog limits resolver.
#[derive(Debug)]
pub struct CatalogLimitsRequest<Ctx> {
/// Model whose supported limits are being discovered.
pub model: String,
/// Owned host context such as configuration and credential sources.
pub context: Ctx,
}

impl<Ctx> std::fmt::Debug for CatalogLimitsRequest<Ctx> {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter
.debug_struct("CatalogLimitsRequest")
.field("model", &self.model)
.field("context", &"<host context>")
.finish()
}
}

/// Builds the provider limit discovery request for a model, if supported.
pub type CatalogLimits<Ctx> =
Arc<dyn Fn(CatalogLimitsRequest<Ctx>) -> CatalogLimitsFuture + Send + Sync>;
Expand Down
14 changes: 14 additions & 0 deletions crates/tinyinference-llm/tests/provider_overrides.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,17 @@ fn registered_chat_entry_exposes_all_provider_model_metadata() {
assert_eq!(request.metadata["caller"], "retained");
assert_eq!(request.metadata["reasoning_disabled"], true);
}

#[test]
fn catalog_limits_request_debug_redacts_the_host_context() {
let request = CatalogLimitsRequest {
model: "gpt-test".to_string(),
context: "sk-live-secret",
};

let printed = format!("{request:?}");

assert!(printed.contains("gpt-test"), "{printed}");
assert!(printed.contains("<host context>"), "{printed}");
assert!(!printed.contains("sk-live-secret"), "{printed}");
}
Loading