13 lines
619 B
TypeScript
13 lines
619 B
TypeScript
import type { LanguageModelV3Middleware } from '@ai-sdk/provider';
|
|
import { createSmartAiCachingMiddleware } from './smartai.cache.js';
|
|
import type { ISmartAiCacheOptions } from './smartai.cache.js';
|
|
|
|
/**
|
|
* Creates middleware that adds Anthropic prompt caching directives.
|
|
* Marks the last system message and last user message with ephemeral cache control,
|
|
* reducing input token cost and latency on repeated calls.
|
|
*/
|
|
export function createAnthropicCachingMiddleware(options: ISmartAiCacheOptions = {}): LanguageModelV3Middleware {
|
|
return createSmartAiCachingMiddleware({ ...options, provider: 'anthropic' });
|
|
}
|