| 146 | cachingAtDepth += convertedPrompt.messages[messageCount - 1].role === 'assistant' ? 1 : 0; | 146 | cachingAtDepth += convertedPrompt.messages[messageCount - 1].role === 'assistant' ? 1 : 0; |
| 147 | | 147 | |
| 148 | if (messageCount - 1 - cachingAtDepth >= 0) { | 148 | if (messageCount - 1 - cachingAtDepth >= 0) { |
| 149 | convertedPrompt.messages[messageCount - 1 - cachingAtDepth]['cache_control'] = { type: 'ephemeral' }; | 149 | const contentCount = convertedPrompt.messages[messageCount - 1 - cachingAtDepth].content.length; |
| | 150 | convertedPrompt.messages[messageCount - 1 - cachingAtDepth].content[contentCount - 1]['cache_control'] = { type: 'ephemeral' }; |
| 150 | } | 151 | } |
| 151 | | 152 | |
| 152 | if (messageCount - 1 - cachingAtDepth - 2 >= 0) { | 153 | if (messageCount - 1 - cachingAtDepth - 2 >= 0) { |
| 153 | convertedPrompt.messages[messageCount - 1 - cachingAtDepth - 2]['cache_control'] = { type: 'ephemeral' }; | 154 | const contentCount = convertedPrompt.messages[messageCount - 1 - cachingAtDepth].content.length; |
| | 155 | convertedPrompt.messages[messageCount - 1 - cachingAtDepth - 2].content[contentCount - 1]['cache_control'] = { type: 'ephemeral' }; |
| 154 | } | 156 | } |
| 155 | } | 157 | } |
| 156 | | 158 | |