Introduce promptCaching option
This commit is contained in:
parent
820acc869b
commit
6b8345e792
4 changed files with 5 additions and 5 deletions
|
|
@ -852,7 +852,6 @@ declare global {
|
|||
export interface CacheBehavior {
|
||||
cacheSystemMessage?: boolean;
|
||||
cacheConversation?: boolean;
|
||||
cacheToolsConfig?: boolean;
|
||||
}
|
||||
|
||||
export interface ClientCertificateOptions {
|
||||
|
|
|
|||
2
core/index.d.ts
vendored
2
core/index.d.ts
vendored
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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>;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue