MCPcopy Create free account
hub / github.com/InferCore/InferCore / SelectRoute

Method SelectRoute

internal/router/rule_router.go:24–36  ·  view source on GitHub ↗
(ctx context.Context, req types.AIRequest, state types.RuntimeState)

Source from the content-addressed store, hash-verified

22}
23
24func (r *RuleRouter) SelectRoute(ctx context.Context, req types.AIRequest, state types.RuntimeState) (types.RouteDecision, error) {
25 if err := ctx.Err(); err != nil {
26 return types.RouteDecision{}, err
27 }
28 tenant, _ := r.cfg.TenantByID(req.TenantID)
29 baseDecision, err := r.selectByRules(tenant, req, state)
30 if err != nil {
31 return types.RouteDecision{}, err
32 }
33
34 optimized := r.optimizeByCost(tenant, req, baseDecision, state)
35 return optimized, nil
36}
37
38// BackendHealthOK mirrors routing semantics: unknown backends are treated as selectable.
39func BackendHealthOK(health map[string]bool, backendName string) bool {

Calls 3

selectByRulesMethod · 0.95
optimizeByCostMethod · 0.95
TenantByIDMethod · 0.80