MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / parseClaudeResponse

Function parseClaudeResponse

cmd/inject-cli/main.go:959–986  ·  view source on GitHub ↗
(raw string)

Source from the content-addressed store, hash-verified

957}
958
959func 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
988func parseOpenAIRequest(raw string) {
989 messages := gjson.Get(raw,"messages")

Callers 1

printObserveEventFunction · 0.70

Calls 4

printTruncatedFunction · 0.85
truncateFunction · 0.70
GetMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected