(raw string)
| 957 | } |
| 958 | |
| 959 | func parseClaudeResponse(raw string) { |
| 960 | // For streaming responses, raw is accumulated SSE chunks — try to extract content blocks |
| 961 | // For non-streaming, it's a single JSON object |
| 962 | content := gjson.Get(raw,"content") |
| 963 | if content.Exists() && content.IsArray() { |
| 964 | role := gjson.Get(raw,"role").String() |
| 965 | if role == "" { |
| 966 | role = "assistant" |
| 967 | } |
| 968 | for _, block := range content.Array() { |
| 969 | blockType := block.Get("type").String() |
| 970 | switch blockType { |
| 971 | case "text": |
| 972 | text := block.Get("text").String() |
| 973 | fmt.Printf(" \033[36m%s:\033[0m %s\n", role, truncate(text, 200)) |
| 974 | case "tool_use": |
| 975 | name := block.Get("name").String() |
| 976 | input := block.Get("input").Raw |
| 977 | fmt.Printf(" \033[36m[tool_use: %s]\033[0m %s\n", name, truncate(input, 150)) |
| 978 | default: |
| 979 | fmt.Printf(" \033[36m[%s]\033[0m %s\n", blockType, truncate(block.Raw, 100)) |
| 980 | } |
| 981 | } |
| 982 | return |
| 983 | } |
| 984 | // Fallback: show truncated raw |
| 985 | printTruncated(raw, 500) |
| 986 | } |
| 987 | |
| 988 | func parseOpenAIRequest(raw string) { |
| 989 | messages := gjson.Get(raw,"messages") |
no test coverage detected