fix: satisfy errcheck for reasoning content conversion

This commit is contained in:
L494264Tt 2026-05-19 17:17:39 +08:00
parent 6082d02d22
commit fe3283a1d5

View File

@ -150,12 +150,10 @@ func chatUserToResponses(m ChatMessage) ([]ResponsesInputItem, error) {
// empty/nil and there are tool_calls, only function_call items are emitted.
func chatAssistantToResponses(m ChatMessage) ([]ResponsesInputItem, error) {
var items []ResponsesInputItem
var content strings.Builder
content := ""
if m.ReasoningContent != "" {
content.WriteString("<thinking>")
content.WriteString(m.ReasoningContent)
content.WriteString("</thinking>")
content = "<thinking>" + m.ReasoningContent + "</thinking>"
}
// Emit assistant message with output_text if content is non-empty.
@ -165,15 +163,15 @@ func chatAssistantToResponses(m ChatMessage) ([]ResponsesInputItem, error) {
return nil, err
}
if s != "" {
if content.Len() > 0 {
content.WriteByte('\n')
if content != "" {
content += "\n"
}
content.WriteString(s)
content += s
}
}
if content.Len() > 0 {
parts := []ResponsesContentPart{{Type: "output_text", Text: content.String()}}
if content != "" {
parts := []ResponsesContentPart{{Type: "output_text", Text: content}}
partsJSON, err := json.Marshal(parts)
if err != nil {
return nil, err