MCPcopy Create free account
hub / github.com/astercloud/aster / ShouldUseToolChoice

Method ShouldUseToolChoice

pkg/tools/constraints.go:246–266  ·  view source on GitHub ↗

ShouldUseToolChoice 判断是否应该使用 tool_choice

(ctx context.Context, constraints ToolConstraints)

Source from the content-addressed store, hash-verified

244
245// ShouldUseToolChoice 判断是否应该使用 tool_choice
246func (s *DefaultToolSelector) ShouldUseToolChoice(ctx context.Context, constraints ToolConstraints) (*ToolChoice, bool) {
247 if constraints == nil {
248 return nil, false
249 }
250
251 switch constraints.GetConstraintType() {
252 case ConstraintTypeRequired:
253 // 必需工具约束 -> 使用 tool_choice
254 if req, ok := constraints.(*RequiredToolConstraints); ok {
255 return ToolChoiceRequired(req.GetRequiredTool()), true
256 }
257 return nil, false
258
259 case ConstraintTypeAuto:
260 // 自动选择 -> 使用 auto
261 return ToolChoiceAuto, true
262
263 default:
264 return nil, false
265 }
266}
267
268// ConstraintsBuilder 约束构建器
269type ConstraintsBuilder struct {

Calls 3

ToolChoiceRequiredFunction · 0.85
GetRequiredToolMethod · 0.80
GetConstraintTypeMethod · 0.65