mirror of
https://github.com/CJackHwang/ds2api.git
synced 2026-05-05 00:45:29 +08:00
27 lines
655 B
Go
27 lines
655 B
Go
package shared
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"ds2api/internal/toolcall"
|
|
)
|
|
|
|
func DetectAssistantToolCalls(text, exposedThinking, detectionThinking string, toolNames []string) toolcall.ToolCallParseResult {
|
|
textParsed := toolcall.ParseStandaloneToolCallsDetailed(text, toolNames)
|
|
if len(textParsed.Calls) > 0 {
|
|
return textParsed
|
|
}
|
|
if strings.TrimSpace(text) != "" {
|
|
return textParsed
|
|
}
|
|
thinking := detectionThinking
|
|
if strings.TrimSpace(thinking) == "" {
|
|
thinking = exposedThinking
|
|
}
|
|
thinkingParsed := toolcall.ParseStandaloneToolCallsDetailed(thinking, toolNames)
|
|
if len(thinkingParsed.Calls) > 0 {
|
|
return thinkingParsed
|
|
}
|
|
return textParsed
|
|
}
|