haixunMaster/haixun-backend/internal/library/knowledge/expand_strategy.go

40 lines
951 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package knowledge
import "strings"
type ExpandStrategy string
const (
ExpandStrategyBrave ExpandStrategy = "brave"
ExpandStrategyLLM ExpandStrategy = "llm"
ExpandStrategyHybrid ExpandStrategy = "hybrid"
)
func ParseExpandStrategy(raw string) ExpandStrategy {
switch strings.ToLower(strings.TrimSpace(raw)) {
case string(ExpandStrategyLLM):
return ExpandStrategyLLM
case string(ExpandStrategyHybrid):
return ExpandStrategyHybrid
default:
return ExpandStrategyBrave
}
}
func (s ExpandStrategy) RequiresWebSearch() bool {
return s == ExpandStrategyBrave || s == ExpandStrategyHybrid
}
func (s ExpandStrategy) RequiresBrave() bool {
return s.RequiresWebSearch()
}
// UsesSupplementalBrave 廣度補充是否再打第二輪 Bravehybrid 改由 LLM 補廣度以省 API
func (s ExpandStrategy) UsesSupplementalBrave() bool {
return s == ExpandStrategyBrave
}
func (s ExpandStrategy) String() string {
return string(s)
}