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

Function parseResponsesRequest

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

Source from the content-addressed store, hash-verified

1026}
1027
1028func parseResponsesRequest(raw string) {
1029 input := gjson.Get(raw,"input")
1030 if !input.Exists() || !input.IsArray() {
1031 printTruncated(raw, 500)
1032 return
1033 }
1034 arr := input.Array()
1035 start := len(arr) - 3
1036 if start < 0 {
1037 start = 0
1038 }
1039 for _, item := range arr[start:] {
1040 itemType := item.Get("type").String()
1041 role := item.Get("role").String()
1042 if role == "" {
1043 role = itemType
1044 }
1045 content := item.Get("content").String()
1046 if content == "" {
1047 // content may be an array
1048 contentArr := item.Get("content")
1049 if contentArr.IsArray() {
1050 for _, c := range contentArr.Array() {
1051 cType := c.Get("type").String()
1052 text := c.Get("text").String()
1053 if text != "" {
1054 fmt.Printf(" \033[36m%s:\033[0m %s\n", role, truncate(text, 200))
1055 } else {
1056 fmt.Printf(" \033[36m%s [%s]\033[0m %s\n", role, cType, truncate(c.Raw, 100))
1057 }
1058 }
1059 continue
1060 }
1061 }
1062 fmt.Printf(" \033[36m%s:\033[0m %s\n", role, truncate(content, 200))
1063 }
1064}
1065
1066func parseResponsesResponse(raw string) {
1067 output := gjson.Get(raw,"output")

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