(blocks *[]cacheablePromptBlock, system interface{})
| 284 | } |
| 285 | |
| 286 | func appendSystemCacheBlocks(blocks *[]cacheablePromptBlock, system interface{}) { |
| 287 | switch v := system.(type) { |
| 288 | case string: |
| 289 | appendPromptBlock(blocks, map[string]interface{}{ |
| 290 | "kind": "system", |
| 291 | "system_index": 0, |
| 292 | "block": map[string]interface{}{ |
| 293 | "type": "text", |
| 294 | "text": v, |
| 295 | }, |
| 296 | }, false) |
| 297 | case []interface{}: |
| 298 | for i, block := range v { |
| 299 | appendPromptBlock(blocks, map[string]interface{}{ |
| 300 | "kind": "system", |
| 301 | "system_index": i, |
| 302 | "block": block, |
| 303 | }, false) |
| 304 | } |
| 305 | case []string: |
| 306 | for i, block := range v { |
| 307 | appendPromptBlock(blocks, map[string]interface{}{ |
| 308 | "kind": "system", |
| 309 | "system_index": i, |
| 310 | "block": map[string]interface{}{ |
| 311 | "type": "text", |
| 312 | "text": block, |
| 313 | }, |
| 314 | }, false) |
| 315 | } |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | func appendMessageCacheBlocks(blocks *[]cacheablePromptBlock, messageIndex int, msg ClaudeMessage) { |
| 320 | role := msg.Role |
no test coverage detected