(system_blocks: list[dict[str, Any]], max_blocks: int = 4)
| 355 | |
| 356 | |
| 357 | def _cap_cache_control(system_blocks: list[dict[str, Any]], max_blocks: int = 4) -> None: |
| 358 | if len(system_blocks) <= max_blocks: |
| 359 | return |
| 360 | keep_indices = {0} | set(range(len(system_blocks) - (max_blocks - 1), len(system_blocks))) |
| 361 | for i, block in enumerate(system_blocks): |
| 362 | if i not in keep_indices and "cache_control" in block: |
| 363 | del block["cache_control"] |
| 364 | |
| 365 | |
| 366 | def _add_conversation_cache_control( |
no outgoing calls