mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-05 08:05:12 +00:00
23 lines
561 B
Go
23 lines
561 B
Go
package apicompat
|
|
|
|
import "strings"
|
|
|
|
// responsesReasoningText prefers the visible summary, falling back to raw
|
|
// reasoning text from compatible upstreams that leave the summary empty.
|
|
func responsesReasoningText(item ResponsesOutput) string {
|
|
var text strings.Builder
|
|
for _, part := range item.Summary {
|
|
if part.Type == "summary_text" {
|
|
_, _ = text.WriteString(part.Text)
|
|
}
|
|
}
|
|
if text.Len() == 0 {
|
|
for _, part := range item.Content {
|
|
if part.Type == "reasoning_text" {
|
|
_, _ = text.WriteString(part.Text)
|
|
}
|
|
}
|
|
}
|
|
return text.String()
|
|
}
|