mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Enable prompt caching for Opus
This commit is contained in:
@@ -19,6 +19,7 @@ export class AnthropicHandler implements ApiHandler {
|
|||||||
const modelId = this.getModel().id
|
const modelId = this.getModel().id
|
||||||
switch (modelId) {
|
switch (modelId) {
|
||||||
case "claude-3-5-sonnet-20240620":
|
case "claude-3-5-sonnet-20240620":
|
||||||
|
case "claude-3-opus-20240229":
|
||||||
case "claude-3-haiku-20240307":
|
case "claude-3-haiku-20240307":
|
||||||
/*
|
/*
|
||||||
The latest message will be the new user message, one before will be the assistant message from a previous request, and the user message before that will be a previously cached user message. So we need to mark the latest user message as ephemeral to cache it for the next request, and mark the second to last user message as ephemeral to let the server know the last message to retrieve from the cache for the current request..
|
The latest message will be the new user message, one before will be the assistant message from a previous request, and the user message before that will be a previously cached user message. So we need to mark the latest user message as ephemeral to cache it for the next request, and mark the second to last user message as ephemeral to let the server know the last message to retrieve from the cache for the current request..
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export class KoduHandler implements ApiHandler {
|
|||||||
let requestBody: Anthropic.Beta.PromptCaching.Messages.MessageCreateParamsNonStreaming
|
let requestBody: Anthropic.Beta.PromptCaching.Messages.MessageCreateParamsNonStreaming
|
||||||
switch (modelId) {
|
switch (modelId) {
|
||||||
case "claude-3-5-sonnet-20240620":
|
case "claude-3-5-sonnet-20240620":
|
||||||
|
case "claude-3-opus-20240229":
|
||||||
case "claude-3-haiku-20240307":
|
case "claude-3-haiku-20240307":
|
||||||
const userMsgIndices = messages.reduce(
|
const userMsgIndices = messages.reduce(
|
||||||
(acc, msg, index) => (msg.role === "user" ? [...acc, index] : acc),
|
(acc, msg, index) => (msg.role === "user" ? [...acc, index] : acc),
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export const anthropicModels = {
|
|||||||
"claude-3-opus-20240229": {
|
"claude-3-opus-20240229": {
|
||||||
maxTokens: 4096,
|
maxTokens: 4096,
|
||||||
supportsImages: true,
|
supportsImages: true,
|
||||||
supportsPromptCache: false,
|
supportsPromptCache: true,
|
||||||
inputPrice: 15.0,
|
inputPrice: 15.0,
|
||||||
outputPrice: 75.0,
|
outputPrice: 75.0,
|
||||||
cacheWritesPrice: 18.75,
|
cacheWritesPrice: 18.75,
|
||||||
|
|||||||
Reference in New Issue
Block a user