MCPcopy Create free account
hub / github.com/continuedev/continue / addCacheControlToContent

Method addCacheControlToContent

core/llm/llms/OpenRouter.ts:82–109  ·  view source on GitHub ↗
(content: any, addCaching: boolean)

Source from the content-addressed store, hash-verified

80 }
81
82 private addCacheControlToContent(content: any, addCaching: boolean): any {
83 if (!addCaching) return content;
84
85 if (typeof content === "string") {
86 return [
87 {
88 type: "text",
89 text: content,
90 cache_control: { type: "ephemeral" },
91 },
92 ];
93 }
94
95 if (Array.isArray(content)) {
96 // For array content, add cache_control to the last text item
97 return content.map((part, idx) => {
98 if (part.type === "text" && idx === content.length - 1) {
99 return {
100 ...part,
101 cache_control: { type: "ephemeral" },
102 };
103 }
104 return part;
105 });
106 }
107
108 return content;
109 }
110
111 protected modifyChatBody(
112 body: ChatCompletionCreateParams,

Callers 1

modifyChatBodyMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected