mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-28 10:02:15 +00:00
* fix(deepinfra): load all DeepInfra models when user wants to browse them during onboarding * docs(deepinfra): align TTS default * fix(deepinfra): refresh video fallbacks * fix(deepinfra): share credential-aware catalog discovery * test(deepinfra): narrow catalog regression types * test(deepinfra): keep catalog narrowing across callback * fix(deepinfra): preserve default model in live catalog * fix(deepinfra): align default model pricing * fix(deepinfra): keep pixverse as video default * docs(deepinfra): match video fallback default * fix(deepinfra): honor config api keys for live catalog * test(e2e): wait for watchdog stdio close * test(media): align live harness provider expectation * fix(deepinfra): always augment custom catalogs * test(e2e): resolve watchdog commands before spawning --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
26 lines
1.1 KiB
TypeScript
26 lines
1.1 KiB
TypeScript
import {
|
|
applyAnthropicEphemeralCacheControlMarkers,
|
|
streamWithPayloadPatch,
|
|
} from "openclaw/plugin-sdk/provider-stream";
|
|
|
|
// StreamFn isn't re-exported via the plugin SDK; derive it from a helper that
|
|
// accepts it so we stay on the SDK boundary.
|
|
type StreamFn = Parameters<typeof streamWithPayloadPatch>[0];
|
|
|
|
// Inject Anthropic ephemeral cache_control markers for anthropic/* models on
|
|
// DeepInfra. The OpenRouter equivalent short-circuits on a provider/endpoint
|
|
// check, so DeepInfra advertises isCacheTtlEligible but the payload patch
|
|
// never fires. Gating on the model id instead fixes that.
|
|
export function createDeepInfraAnthropicCacheWrapper(baseStreamFn: StreamFn): StreamFn {
|
|
return ((model, context, options) => {
|
|
const modelIdRaw = (model as { id?: unknown }).id;
|
|
const modelId = typeof modelIdRaw === "string" ? modelIdRaw.toLowerCase() : "";
|
|
if (!modelId.startsWith("anthropic/")) {
|
|
return baseStreamFn(model, context, options);
|
|
}
|
|
return streamWithPayloadPatch(baseStreamFn, model, context, options, (payload) => {
|
|
applyAnthropicEphemeralCacheControlMarkers(payload);
|
|
});
|
|
}) as StreamFn;
|
|
}
|