MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / withoutCacheControl

Function withoutCacheControl

common/src/util/messages.ts:61–90  ·  view source on GitHub ↗
(obj: T)

Source from the content-addressed store, hash-verified

59}
60
61export function withoutCacheControl<
62 T extends { providerOptions?: ProviderMetadata },
63>(obj: T): T {
64 const wrapper = cloneDeep(obj)
65
66 for (const provider of [
67 'anthropic',
68 'openrouter',
69 'openaiCompatible',
70 ] as const) {
71 if (has(wrapper.providerOptions?.[provider]?.cache_control, 'type')) {
72 delete wrapper.providerOptions?.[provider]?.cache_control?.type
73 }
74 if (
75 Object.keys(wrapper.providerOptions?.[provider]?.cache_control ?? {})
76 .length === 0
77 ) {
78 delete wrapper.providerOptions?.[provider]?.cache_control
79 }
80 if (Object.keys(wrapper.providerOptions?.[provider] ?? {}).length === 0) {
81 delete wrapper.providerOptions?.[provider]
82 }
83 }
84
85 if (Object.keys(wrapper.providerOptions ?? {}).length === 0) {
86 delete wrapper.providerOptions
87 }
88
89 return wrapper
90}
91
92type NonStringContent<T extends { content: any }> = Omit<T, 'content'> & {
93 content: Exclude<T['content'], string>

Callers 1

messages.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected