(content gjson.Result)
| 802 | } |
| 803 | |
| 804 | func extractResponsesAPIContent(content gjson.Result) string { |
| 805 | if !content.IsArray() { |
| 806 | return "" |
| 807 | } |
| 808 | var texts []string |
| 809 | content.ForEach(func(_, part gjson.Result) bool { |
| 810 | partType := part.Get("type").String() |
| 811 | if partType == "input_text" || partType == "output_text" || partType == "text" { |
| 812 | if text := part.Get("text").String(); text != "" { |
| 813 | texts = append(texts, text) |
| 814 | } |
| 815 | } |
| 816 | return true |
| 817 | }) |
| 818 | if len(texts) > 0 { |
| 819 | return strings.Join(texts, " ") |
| 820 | } |
| 821 | return "" |
| 822 | } |
| 823 | |
| 824 | // extractSessionID is kept for backward compatibility. |
| 825 | // Deprecated: Use ExtractSessionID instead. |
no test coverage detected