40 lines
951 B
Go
40 lines
951 B
Go
|
|
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 廣度補充是否再打第二輪 Brave(hybrid 改由 LLM 補廣度以省 API)。
|
|||
|
|
func (s ExpandStrategy) UsesSupplementalBrave() bool {
|
|||
|
|
return s == ExpandStrategyBrave
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func (s ExpandStrategy) String() string {
|
|||
|
|
return string(s)
|
|||
|
|
}
|