cache_control positioning fix

ac33e4d66804470dc3e112eb21472a24a52f44c1

Honey Tree <kalakanlogs@proton.me>

1 files changed, +4 -2Showing whitespace changes
src/endpoints/backends/chat-completions.js+4 -2
@@ -146,11 +146,13 @@ async function sendClaudeRequest(request, response) {
146146 cachingAtDepth += convertedPrompt.messages[messageCount - 1].role === 'assistant' ? 1 : 0;
147147
148148 if (messageCount - 1 - cachingAtDepth >= 0) {
149149 const contentCount = convertedPrompt.messages[messageCount - 1 - cachingAtDepth]['cache_control'] = { type: 'ephemeral' }.content.length;
150+ convertedPrompt.messages[messageCount - 1 - cachingAtDepth].content[contentCount - 1]['cache_control'] = { type: 'ephemeral' };
150151 }
151152
152153 if (messageCount - 1 - cachingAtDepth - 2 >= 0) {
153154 const contentCount = convertedPrompt.messages[messageCount - 1 - cachingAtDepth - 2]['cache_control'] = { type: 'ephemeral' }.content.length;
155+ convertedPrompt.messages[messageCount - 1 - cachingAtDepth - 2].content[contentCount - 1]['cache_control'] = { type: 'ephemeral' };
154156 }
155157 }
156158