runRouterWithDeps is runRouter's general form: lets the caller pass a fully-populated ClassifierDeps (ModelLookup, Evaluator, ...) so tests can exercise the template-renderer + stop-token derivation paths, not just the bare-scorer fast path.
(loader *config.ModelConfigLoader, appConfig *config.ApplicationConfig, store router.DecisionStore, routerCfg *config.ModelConfig, parsed any, deps ClassifierDeps)
| 444 | // tests can exercise the template-renderer + stop-token derivation |
| 445 | // paths, not just the bare-scorer fast path. |
| 446 | func runRouterWithDeps(loader *config.ModelConfigLoader, appConfig *config.ApplicationConfig, store router.DecisionStore, routerCfg *config.ModelConfig, parsed any, deps ClassifierDeps) (*httptest.ResponseRecorder, error) { |
| 447 | mw := RouteModel(loader, appConfig, store, nil, OpenAIProbe, router.SourceChat, deps) |
| 448 | req := httptest.NewRequest(http.MethodPost, "/v1/chat/completions", strings.NewReader("{}")) |
| 449 | rec := httptest.NewRecorder() |
| 450 | c := echo.New().NewContext(req, rec) |
| 451 | c.Set(CONTEXT_LOCALS_KEY_MODEL_CONFIG, routerCfg) |
| 452 | c.Set(CONTEXT_LOCALS_KEY_LOCALAI_REQUEST, parsed) |
| 453 | handler := mw(func(c echo.Context) error { |
| 454 | served, _ := c.Get(ContextKeyServedModel).(string) |
| 455 | return c.String(http.StatusOK, "served:"+served) |
| 456 | }) |
| 457 | err := handler(c) |
| 458 | return rec, err |
| 459 | } |
| 460 | |
| 461 | // loaderLookup mirrors application.ModelConfigLookup — bridges the |
| 462 | // loader to the ModelConfigLookup signature ClassifierDeps wants. |