(raw string)
| 1003 | } |
| 1004 | |
| 1005 | func 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 | |
| 1028 | func parseResponsesRequest(raw string) { |
| 1029 | input := gjson.Get(raw,"input") |
no test coverage detected