(
systemPrompt: SystemPrompt,
enablePromptCaching: boolean,
options?: {
skipGlobalCacheForSystemPrompt?: boolean
querySource?: QuerySource
},
)
| 3238 | } |
| 3239 | |
| 3240 | export function buildSystemPromptBlocks( |
| 3241 | systemPrompt: SystemPrompt, |
| 3242 | enablePromptCaching: boolean, |
| 3243 | options?: { |
| 3244 | skipGlobalCacheForSystemPrompt?: boolean |
| 3245 | querySource?: QuerySource |
| 3246 | }, |
| 3247 | ): TextBlockParam[] { |
| 3248 | // IMPORTANT: Do not add any more blocks for caching or you will get a 400 |
| 3249 | return splitSysPromptPrefix(systemPrompt, { |
| 3250 | skipGlobalCacheForSystemPrompt: options?.skipGlobalCacheForSystemPrompt, |
| 3251 | }).map(block => { |
| 3252 | return { |
| 3253 | type: 'text' as const, |
| 3254 | text: block.text, |
| 3255 | ...(enablePromptCaching && |
| 3256 | block.cacheScope !== null && { |
| 3257 | cache_control: getCacheControl({ |
| 3258 | scope: block.cacheScope, |
| 3259 | querySource: options?.querySource, |
| 3260 | }), |
| 3261 | }), |
| 3262 | } |
| 3263 | }) |
| 3264 | } |
| 3265 | |
| 3266 | type HaikuOptions = Omit<Options, 'model' | 'getToolPermissionContext'> |
| 3267 |
no test coverage detected