Warn on high-cost LightRAG and LivingMemory config#199
Conversation
Reviewer's GuideAdds a shared detector for a high-cost LightRAG + LivingMemory configuration and surfaces non-blocking cost warnings through backend validation, config schema/API responses, and the dashboard UI, including expanded docs and tests to cover the new behavior. Sequence diagram for propagating high-cost config warnings to dashboard UIsequenceDiagram
actor User
participant DashboardUI
participant ConfigService
participant IntegrationService
participant PluginConfig
participant get_config_cost_warnings
User->>DashboardUI: open settings page
DashboardUI->>ConfigService: GET /api/config/schema
ConfigService->>PluginConfig: to_dict
ConfigService->>get_config_cost_warnings: get_config_cost_warnings(plugin_config)
get_config_cost_warnings-->>ConfigService: [LIGHTRAG_LIVINGMEMORY_COST_WARNING]
ConfigService-->>DashboardUI: schema (groups, config) + warnings
DashboardUI->>DashboardUI: renderSettings
DashboardUI->>DashboardUI: renderConfigWarnings
User->>DashboardUI: open integrations page
DashboardUI->>IntegrationService: GET /api/integrations/status
IntegrationService->>get_config_cost_warnings: get_config_cost_warnings(config)
get_config_cost_warnings-->>IntegrationService: [LIGHTRAG_LIVINGMEMORY_COST_WARNING]
IntegrationService-->>DashboardUI: settings + dashboards + warnings
DashboardUI->>DashboardUI: renderIntegrations
DashboardUI->>DashboardUI: warningListHtml
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pages/dashboard/app.js" line_range="319-327" />
<code_context>
}, 3200);
}
+ function warningListHtml(warnings) {
+ const items = Array.isArray(warnings) ? warnings.filter(Boolean) : [];
+ return items.map((message) => `
+ <div class="settings-warning">
+ <strong>成本提醒</strong>
</code_context>
<issue_to_address>
**suggestion:** Normalize/trim warning messages before rendering for more consistent output and to match other paths.
`warningListHtml` currently only uses `filter(Boolean)` before escaping. In `dashboard.html`'s `getConfigWarnings`, you also coerce to `String` and `trim()` before filtering, which avoids whitespace-only warnings and normalizes spacing. Apply the same `String(message).trim()` step here so SPA and static dashboard warnings are handled consistently and blank/poorly formatted items aren’t rendered.
```suggestion
function warningListHtml(warnings) {
const items = Array.isArray(warnings)
? warnings
.map((message) => String(message).trim())
.filter(Boolean)
: [];
return items.map((message) => `
<div class="settings-warning">
<strong>成本提醒</strong>
<span>${escapeHtml(message)}</span>
</div>
`).join("");
}
```
</issue_to_address>
### Comment 2
<location path="tests/integration/test_webui_static_assets.py" line_range="276-285" />
<code_context>
assert "GET /api/data/overview" in service
+def test_dashboard_exposes_config_cost_warnings():
+ text = (PLUGIN_ROOT / "web_res" / "static" / "html" / "dashboard.html").read_text(encoding="utf-8")
+ app = (PLUGIN_ROOT / "pages" / "dashboard" / "app.js").read_text(encoding="utf-8")
+ service = (PLUGIN_ROOT / "webui" / "services" / "config_service.py").read_text(encoding="utf-8")
+
+ assert "configWarnings" in text
+ assert "settings-warning-list" in text
+ assert "成本提醒" in text
+ assert "warningListHtml" in app
+ assert "schema.warnings" in app
+ assert "get_config_cost_warnings" in service
+
+
</code_context>
<issue_to_address>
**suggestion (testing):** Consider asserting the presence of the new warning containers (`settings-warnings` / `integration-warnings`) to make the dashboard wiring more robust.
Adding assertions for these DOM containers in `dashboard.html` would ensure the warning slots themselves remain intact, not just the JS symbols. This helps detect template changes that remove or rename the containers while leaving the JS references in place.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| def test_dashboard_exposes_config_cost_warnings(): | ||
| text = (PLUGIN_ROOT / "web_res" / "static" / "html" / "dashboard.html").read_text(encoding="utf-8") | ||
| app = (PLUGIN_ROOT / "pages" / "dashboard" / "app.js").read_text(encoding="utf-8") | ||
| service = (PLUGIN_ROOT / "webui" / "services" / "config_service.py").read_text(encoding="utf-8") | ||
|
|
||
| assert "configWarnings" in text | ||
| assert "settings-warning-list" in text | ||
| assert "成本提醒" in text | ||
| assert "warningListHtml" in app | ||
| assert "schema.warnings" in app |
There was a problem hiding this comment.
suggestion (testing): Consider asserting the presence of the new warning containers (settings-warnings / integration-warnings) to make the dashboard wiring more robust.
Adding assertions for these DOM containers in dashboard.html would ensure the warning slots themselves remain intact, not just the JS symbols. This helps detect template changes that remove or rename the containers while leaving the JS references in place.
c068a66 to
bd3b286
Compare
Closes #198.
Summary
knowledge_engine=lightrag+lightrag_query_mode=hybrid/mix+ LivingMemory memory delegation./api/config/schema, and/api/integrations/status.Validation
python -m json.tool _conf_schema.json > $nullpython -m py_compile config.py webui\services\config_service.py webui\services\integration_service.py tests\unit\test_config.py tests\unit\test_config_service.py tests\unit\test_integration_service.py tests\integration\test_config_blueprint.py tests\integration\test_webui_static_assets.pypython -m ruff check config.py webui\services\config_service.py webui\services\integration_service.py tests\unit\test_config.py tests\unit\test_config_service.py tests\unit\test_integration_service.py tests\integration\test_config_blueprint.py tests\integration\test_webui_static_assets.pypython -m pytest --basetemp .tmp\pytest-temp tests\unit\test_config.py tests\unit\test_config_service.py tests\unit\test_integration_service.py tests\integration\test_config_blueprint.py tests\integration\test_webui_static_assets.py(93 passed)Summary by Sourcery
Add advisory cost warnings for high-cost LightRAG + LivingMemory configurations and surface them across backend APIs, dashboard UI, and documentation.
New Features:
Enhancements:
Tests: