Просмотр исходного кода

Enable prompt caching for Opus

Saoud Rizwan 1 год назад
Родитель
Сommit
5dcf836d81
3 измененных файлов с 3 добавлено и 1 удалено
  1. 1 0
      src/api/anthropic.ts
  2. 1 0
      src/api/kodu.ts
  3. 1 1
      src/shared/api.ts

+ 1 - 0
src/api/anthropic.ts

@@ -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..

+ 1 - 0
src/api/kodu.ts

@@ -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),

+ 1 - 1
src/shared/api.ts

@@ -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,