fix: satisfy errcheck for reasoning content conversion
This commit is contained in:
parent
6082d02d22
commit
fe3283a1d5
@ -150,12 +150,10 @@ func chatUserToResponses(m ChatMessage) ([]ResponsesInputItem, error) {
|
|||||||
// empty/nil and there are tool_calls, only function_call items are emitted.
|
// empty/nil and there are tool_calls, only function_call items are emitted.
|
||||||
func chatAssistantToResponses(m ChatMessage) ([]ResponsesInputItem, error) {
|
func chatAssistantToResponses(m ChatMessage) ([]ResponsesInputItem, error) {
|
||||||
var items []ResponsesInputItem
|
var items []ResponsesInputItem
|
||||||
var content strings.Builder
|
content := ""
|
||||||
|
|
||||||
if m.ReasoningContent != "" {
|
if m.ReasoningContent != "" {
|
||||||
content.WriteString("<thinking>")
|
content = "<thinking>" + m.ReasoningContent + "</thinking>"
|
||||||
content.WriteString(m.ReasoningContent)
|
|
||||||
content.WriteString("</thinking>")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Emit assistant message with output_text if content is non-empty.
|
// Emit assistant message with output_text if content is non-empty.
|
||||||
@ -165,15 +163,15 @@ func chatAssistantToResponses(m ChatMessage) ([]ResponsesInputItem, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if s != "" {
|
if s != "" {
|
||||||
if content.Len() > 0 {
|
if content != "" {
|
||||||
content.WriteByte('\n')
|
content += "\n"
|
||||||
}
|
}
|
||||||
content.WriteString(s)
|
content += s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if content.Len() > 0 {
|
if content != "" {
|
||||||
parts := []ResponsesContentPart{{Type: "output_text", Text: content.String()}}
|
parts := []ResponsesContentPart{{Type: "output_text", Text: content}}
|
||||||
partsJSON, err := json.Marshal(parts)
|
partsJSON, err := json.Marshal(parts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user