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

Function parseOpenAIResponse

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

Source from the content-addressed store, hash-verified

1003}
1004
1005func parseOpenAIResponse(raw string) {
1006 // Non-streaming: single JSON with choices
1007 msg := gjson.Get(raw,"choices.0.message")
1008 if msg.Exists() {
1009 role := msg.Get("role").String()
1010 content := msg.Get("content").String()
1011 if content != "" {
1012 fmt.Printf(" \033[36m%s:\033[0m %s\n", role, truncate(content, 200))
1013 }
1014 toolCalls := msg.Get("tool_calls")
1015 if toolCalls.Exists() && toolCalls.IsArray() {
1016 for _, tc := range toolCalls.Array() {
1017 name := tc.Get("function.name").String()
1018 args := tc.Get("function.arguments").String()
1019 fmt.Printf(" \033[36m[tool_call: %s]\033[0m %s\n", name, truncate(args, 150))
1020 }
1021 }
1022 return
1023 }
1024 // Streaming: accumulated SSE data lines
1025 printTruncated(raw, 500)
1026}
1027
1028func parseResponsesRequest(raw string) {
1029 input := gjson.Get(raw,"input")

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