Introduce promptCaching option

This commit is contained in:
chezsmithy 2025-05-08 21:08:13 -07:00
parent 820acc869b
commit 6b8345e792
4 changed files with 5 additions and 5 deletions

View file

@ -852,7 +852,6 @@ declare global {
export interface CacheBehavior {
cacheSystemMessage?: boolean;
cacheConversation?: boolean;
cacheToolsConfig?: boolean;
}
export interface ClientCertificateOptions {

2
core/index.d.ts vendored
View file

@ -927,7 +927,6 @@ export interface RequestOptions {
export interface CacheBehavior {
cacheSystemMessage?: boolean;
cacheConversation?: boolean;
cacheToolsConfig?: boolean;
}
export interface ClientCertificateOptions {
@ -1024,6 +1023,7 @@ export interface BaseCompletionOptions {
toolChoice?: ToolChoice;
reasoning?: boolean;
reasoningBudgetTokens?: number;
promptCaching?: boolean;
}
export interface ModelCapability {

View file

@ -292,10 +292,10 @@ class Bedrock extends BaseLLM {
const convertedMessages = this._convertMessages(messages);
const shouldCacheSystemMessage =
!!systemMessage && this.cacheBehavior?.cacheSystemMessage;
!!systemMessage && this.cacheBehavior?.cacheSystemMessage || this.completionOptions.promptCaching;
const enablePromptCaching =
shouldCacheSystemMessage || this.cacheBehavior?.cacheConversation;
const shouldCacheToolsConfig = this.cacheBehavior?.cacheToolsConfig;
shouldCacheSystemMessage || this.cacheBehavior?.cacheConversation || this.completionOptions.promptCaching;
const shouldCacheToolsConfig = this.completionOptions.promptCaching;
// Add header for prompt caching
if (enablePromptCaching) {

View file

@ -49,6 +49,7 @@ export const completionOptionsSchema = z.object({
n: z.number().optional(),
reasoning: z.boolean().optional(),
reasoningBudgetTokens: z.number().optional(),
promptCaching: z.boolean().optional(),
});
export type CompletionOptions = z.infer<typeof completionOptionsSchema>;