This commit is contained in:
Saoud Rizwan
2024-10-06 08:50:04 -04:00
parent d0bf4f3711
commit 8f4a65bc79
2 changed files with 11 additions and 9 deletions

View File

@@ -46,6 +46,7 @@ export class OpenRouterHandler implements ApiHandler {
],
}
// Add cache_control to the last two user messages
// (note: this works because we only ever add one user message at a time, but if we added multiple we'd need to mark the user message before the last assistant message)
const lastTwoUserMessages = openAiMessages.filter((msg) => msg.role === "user").slice(-2)
lastTwoUserMessages.forEach((msg) => {
if (typeof msg.content === "string") {