Add claude 1 hour caching
This commit is contained in:
@@ -1130,5 +1130,5 @@ export const languageEnglish = {
|
|||||||
promptInfoEmptyText: "No prompt text has been saved.",
|
promptInfoEmptyText: "No prompt text has been saved.",
|
||||||
escapeOutput: "Escape Output",
|
escapeOutput: "Escape Output",
|
||||||
claudeBatching: "Claude Batching",
|
claudeBatching: "Claude Batching",
|
||||||
|
claude1HourCaching: "Claude 1 Hour Caching",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2949,7 +2949,10 @@ async function requestClaude(arg:RequestDataArgumentExtended):Promise<requestDat
|
|||||||
interface Claude3TextBlock {
|
interface Claude3TextBlock {
|
||||||
type: 'text',
|
type: 'text',
|
||||||
text: string,
|
text: string,
|
||||||
cache_control?: {"type": "ephemeral"}
|
cache_control?: {
|
||||||
|
"type": "ephemeral",
|
||||||
|
"ttl"?: "5m" | "1h"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Claude3ImageBlock {
|
interface Claude3ImageBlock {
|
||||||
@@ -2959,7 +2962,10 @@ async function requestClaude(arg:RequestDataArgumentExtended):Promise<requestDat
|
|||||||
media_type: string,
|
media_type: string,
|
||||||
data: string
|
data: string
|
||||||
}
|
}
|
||||||
cache_control?: {"type": "ephemeral"}
|
cache_control?: {
|
||||||
|
"type": "ephemeral"
|
||||||
|
"ttl"?: "5m" | "1h"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Claude3ContentBlock = Claude3TextBlock|Claude3ImageBlock
|
type Claude3ContentBlock = Claude3TextBlock|Claude3ImageBlock
|
||||||
@@ -3024,8 +3030,17 @@ async function requestClaude(arg:RequestDataArgumentExtended):Promise<requestDat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(chat.cache){
|
if(chat.cache){
|
||||||
content[content.length-1].cache_control = {
|
|
||||||
type: 'ephemeral'
|
if(db.claude1HourCaching){
|
||||||
|
content[content.length-1].cache_control = {
|
||||||
|
type: 'ephemeral',
|
||||||
|
ttl: "1h"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
content[content.length-1].cache_control = {
|
||||||
|
type: 'ephemeral'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
claudeChat[claudeChat.length-1].content = content
|
claudeChat[claudeChat.length-1].content = content
|
||||||
@@ -3317,6 +3332,11 @@ async function requestClaude(arg:RequestDataArgumentExtended):Promise<requestDat
|
|||||||
betas.push('output-128k-2025-02-19')
|
betas.push('output-128k-2025-02-19')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(db.claude1HourCaching){
|
||||||
|
betas.push('extended-cache-ttl-2025-04-11')
|
||||||
|
}
|
||||||
|
|
||||||
if(betas.length > 0){
|
if(betas.length > 0){
|
||||||
headers['anthropic-beta'] = betas.join(',')
|
headers['anthropic-beta'] = betas.join(',')
|
||||||
}
|
}
|
||||||
@@ -3325,6 +3345,7 @@ async function requestClaude(arg:RequestDataArgumentExtended):Promise<requestDat
|
|||||||
headers['anthropic-dangerous-direct-browser-access'] = 'true'
|
headers['anthropic-dangerous-direct-browser-access'] = 'true'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(arg.previewBody){
|
if(arg.previewBody){
|
||||||
return {
|
return {
|
||||||
type: 'success',
|
type: 'success',
|
||||||
|
|||||||
@@ -1033,6 +1033,7 @@ export interface Database{
|
|||||||
promptInfoInsideChat:boolean
|
promptInfoInsideChat:boolean
|
||||||
promptTextInfoInsideChat:boolean
|
promptTextInfoInsideChat:boolean
|
||||||
claudeBatching:boolean
|
claudeBatching:boolean
|
||||||
|
claude1HourCaching:boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface SeparateParameters{
|
interface SeparateParameters{
|
||||||
|
|||||||
Reference in New Issue
Block a user