[PR #5478] [MERGED] Model Router: Multi-condition rules, updated designs, and router edit support #5458

Closed
opened 2026-06-05 15:21:25 -04:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Mintplex-Labs/anything-llm/pull/5478
Author: @angelplusultra
Created: 4/21/2026
Status: Merged
Merged: 4/21/2026
Merged by: @shatfield4

Base: 5313-feat-model-routerHead: 5313-model-router-designs-and-feature-expansion


📝 Commits (5)

  • 4a7e196 Implement draft designs
  • 41cdde1 add matches comparator for prompt content
  • 756d645 implement multi conditional to a calculated rule
  • 9a37157 fix between comparator
  • 95cca9e restyle model router modals to match light mode designs

📊 Changes

15 files changed (+1084 additions, -730 deletions)

View changed files

📝 frontend/src/locales/en/common.js (+17 -2)
📝 frontend/src/pages/GeneralSettings/ModelRouters/LLMProviderModelPicker/index.jsx (+16 -16)
📝 frontend/src/pages/GeneralSettings/ModelRouters/NewRouterModal/index.jsx (+132 -92)
📝 frontend/src/pages/GeneralSettings/ModelRouters/RouterForm/index.jsx (+7 -121)
📝 frontend/src/pages/GeneralSettings/ModelRouters/RuleBuilder/RuleForm/CalculatedFields/index.jsx (+239 -81)
📝 frontend/src/pages/GeneralSettings/ModelRouters/RuleBuilder/RuleForm/LLMDescriptionField/index.jsx (+3 -3)
📝 frontend/src/pages/GeneralSettings/ModelRouters/RuleBuilder/RuleForm/index.jsx (+145 -127)
📝 frontend/src/pages/GeneralSettings/ModelRouters/RuleBuilder/RuleRow/index.jsx (+96 -49)
📝 frontend/src/pages/GeneralSettings/ModelRouters/RuleBuilder/index.jsx (+63 -52)
📝 frontend/src/pages/GeneralSettings/ModelRouters/index.jsx (+127 -102)
📝 server/models/modelRouter.js (+9 -3)
📝 server/models/modelRouterRule.js (+97 -53)
server/prisma/migrations/20260417000000_router_rules_multi_condition/migration.sql (+56 -0)
📝 server/prisma/schema.prisma (+22 -16)
📝 server/utils/router/deterministic.js (+55 -13)

📄 Description

To be merged into #5324

Summary

  • Multi-condition calculated rules — Rules now support multiple conditions joined by AND/OR logic, replacing the single property/comparator/value model. Includes a DB migration that converts existing single-condition rules into the new JSON array format.
  • matches (regex) comparator — New string comparator for prompt content with /pattern/flags syntax support and input cap to guard against catastrophic backtracking.
  • between comparator fix — Moved between handling before scalar Number() coercion so "9,17" no longer parses as NaN.
  • UI redesign — Router list page swapped from <table> to a grid layout with proper empty states, clickable rows, and inline edit/delete. Rule builder now uses modals (via ModalWrapper) for both create and edit instead of inline forms. Rule rows show multi-condition summaries with AND/ANY quantifiers.
  • Router edit via modalNewRouterModal now doubles as an edit modal (accepts optional router prop), removing the duplicated form from RouterForm. The detail page now only renders the RuleBuilder.
  • Condition UICalculatedFields rewritten as a dynamic condition list with add/remove rows, an AND/OR logic toggle, comparator-aware value placeholders, and contextual help text.
  • Server hydration layer_hydrate() on ModelRouterRule parses the stored JSON conditions string everywhere rules are returned (create, update, get, list), so the API always returns parsed arrays.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Mintplex-Labs/anything-llm/pull/5478 **Author:** [@angelplusultra](https://github.com/angelplusultra) **Created:** 4/21/2026 **Status:** ✅ Merged **Merged:** 4/21/2026 **Merged by:** [@shatfield4](https://github.com/shatfield4) **Base:** `5313-feat-model-router` ← **Head:** `5313-model-router-designs-and-feature-expansion` --- ### 📝 Commits (5) - [`4a7e196`](https://github.com/Mintplex-Labs/anything-llm/commit/4a7e19655c7dab90a0c78d42b5ada2458e386940) Implement draft designs - [`41cdde1`](https://github.com/Mintplex-Labs/anything-llm/commit/41cdde1e0de3c0a0be1f8406f9a5a457c49922d3) add matches comparator for prompt content - [`756d645`](https://github.com/Mintplex-Labs/anything-llm/commit/756d645ba78d63897b911244c1528ea96f373572) implement multi conditional to a calculated rule - [`9a37157`](https://github.com/Mintplex-Labs/anything-llm/commit/9a37157c7daa0bac6629ef7f4c89d2c6d7d60501) fix between comparator - [`95cca9e`](https://github.com/Mintplex-Labs/anything-llm/commit/95cca9e361662196231d4444a9bc56e3dce7360e) restyle model router modals to match light mode designs ### 📊 Changes **15 files changed** (+1084 additions, -730 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/locales/en/common.js` (+17 -2) 📝 `frontend/src/pages/GeneralSettings/ModelRouters/LLMProviderModelPicker/index.jsx` (+16 -16) 📝 `frontend/src/pages/GeneralSettings/ModelRouters/NewRouterModal/index.jsx` (+132 -92) 📝 `frontend/src/pages/GeneralSettings/ModelRouters/RouterForm/index.jsx` (+7 -121) 📝 `frontend/src/pages/GeneralSettings/ModelRouters/RuleBuilder/RuleForm/CalculatedFields/index.jsx` (+239 -81) 📝 `frontend/src/pages/GeneralSettings/ModelRouters/RuleBuilder/RuleForm/LLMDescriptionField/index.jsx` (+3 -3) 📝 `frontend/src/pages/GeneralSettings/ModelRouters/RuleBuilder/RuleForm/index.jsx` (+145 -127) 📝 `frontend/src/pages/GeneralSettings/ModelRouters/RuleBuilder/RuleRow/index.jsx` (+96 -49) 📝 `frontend/src/pages/GeneralSettings/ModelRouters/RuleBuilder/index.jsx` (+63 -52) 📝 `frontend/src/pages/GeneralSettings/ModelRouters/index.jsx` (+127 -102) 📝 `server/models/modelRouter.js` (+9 -3) 📝 `server/models/modelRouterRule.js` (+97 -53) ➕ `server/prisma/migrations/20260417000000_router_rules_multi_condition/migration.sql` (+56 -0) 📝 `server/prisma/schema.prisma` (+22 -16) 📝 `server/utils/router/deterministic.js` (+55 -13) </details> ### 📄 Description To be merged into #5324 ## Summary - **Multi-condition calculated rules** — Rules now support multiple conditions joined by AND/OR logic, replacing the single property/comparator/value model. Includes a DB migration that converts existing single-condition rules into the new JSON array format. - **`matches` (regex) comparator** — New string comparator for prompt content with `/pattern/flags` syntax support and input cap to guard against catastrophic backtracking. - **`between` comparator fix** — Moved `between` handling before scalar `Number()` coercion so `"9,17"` no longer parses as `NaN`. - **UI redesign** — Router list page swapped from `<table>` to a grid layout with proper empty states, clickable rows, and inline edit/delete. Rule builder now uses modals (via `ModalWrapper`) for both create and edit instead of inline forms. Rule rows show multi-condition summaries with AND/ANY quantifiers. - **Router edit via modal** — `NewRouterModal` now doubles as an edit modal (accepts optional `router` prop), removing the duplicated form from `RouterForm`. The detail page now only renders the `RuleBuilder`. - **Condition UI** — `CalculatedFields` rewritten as a dynamic condition list with add/remove rows, an AND/OR logic toggle, comparator-aware value placeholders, and contextual help text. - **Server hydration layer** — `_hydrate()` on `ModelRouterRule` parses the stored JSON `conditions` string everywhere rules are returned (create, update, get, list), so the API always returns parsed arrays. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-06-05 15:21:25 -04:00
yindo closed this issue 2026-06-05 15:21:25 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#5458