mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2026-09-30 01:05:53 +00:00
LLM UI - When LLM is disabled, hide it from the groups settings also (#4471)
This commit is contained in:
@@ -6,7 +6,7 @@ from loguru import logger
|
||||
from changedetectionio.blueprint.tags.colour import safe_css_colour
|
||||
from changedetectionio.store import ChangeDetectionStore
|
||||
from changedetectionio.flask_app import login_optionally_required
|
||||
from changedetectionio.llm.evaluator import get_llm_config as _get_llm_config
|
||||
from changedetectionio.llm.evaluator import get_llm_config as _get_llm_config, is_llm_features_disabled
|
||||
|
||||
|
||||
def construct_blueprint(datastore: ChangeDetectionStore):
|
||||
@@ -230,6 +230,7 @@ def construct_blueprint(datastore: ChangeDetectionStore):
|
||||
output = render_template("edit-tag.html",
|
||||
extra_form_content=included_content,
|
||||
extra_tab_content=form.extra_tab_content() if form.extra_tab_content() else None,
|
||||
llm_features_disabled=is_llm_features_disabled(),
|
||||
matching_watches=matching_watches,
|
||||
settings_application=datastore.data['settings']['application'],
|
||||
**template_args
|
||||
|
||||
@@ -29,7 +29,9 @@
|
||||
<li class="tab" id=""><a href="#general">{{ _('General') }}</a></li>
|
||||
{# Always shown, like the watch edit page: with no provider configured the pane
|
||||
explains how to set one up (and carries the AI switches through on save). #}
|
||||
{%- if not llm_features_disabled %}
|
||||
<li class="tab"><a href="#ai-llm">{{ _('AI / LLM') }}</a></li>
|
||||
{%- endif -%}
|
||||
<li class="tab"><a href="#filters-and-triggers">{{ _('Filters & Triggers') }}</a></li>
|
||||
{% if extra_tab_content %}
|
||||
<li class="tab"><a href="#extras_tab">{{ extra_tab_content }}</a></li>
|
||||
@@ -91,11 +93,11 @@
|
||||
</script>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
{%- if not llm_features_disabled %}
|
||||
<div class="tab-pane-inner" id="ai-llm">
|
||||
{% include "edit/include_llm_intent.html" %}
|
||||
</div>
|
||||
|
||||
{%- endif -%}
|
||||
<div class="tab-pane-inner" id="filters-and-triggers">
|
||||
{# TRANSLATORS: CJK fonts lack native italics; allow substitution with conventional local styling. dennis-ignore: W303 #}
|
||||
<p>{{ _('These settings are <strong><i>added</i></strong> to any existing watch configurations.')|safe }}</p>
|
||||
|
||||
@@ -47,7 +47,8 @@ def test_llm_features_disabled_hides_ui(client, live_server, monkeypatch):
|
||||
_llm_markers_absent(res.data, where='settings')
|
||||
|
||||
# 3. Edit page for a watch (should not have an AI / LLM tab or include_llm_intent body)
|
||||
uuid = datastore.add_watch(url='http://example.com', extras={'title': 'Disabled LLM watch'})
|
||||
uuid = datastore.add_watch(url='http://example.com', extras={'title': 'Disabled LLM watch'}, tag="LLMgroup")
|
||||
tag_uuid = live_server.app.config['DATASTORE'].data['watching'][uuid]['tags'][0]
|
||||
res = client.get(url_for('ui.ui_edit.edit_page', uuid=uuid))
|
||||
assert res.status_code == 200
|
||||
_llm_markers_absent(res.data, where='edit')
|
||||
@@ -55,6 +56,11 @@ def test_llm_features_disabled_hides_ui(client, live_server, monkeypatch):
|
||||
assert b'name="llm_intent"' not in res.data
|
||||
assert b'name="llm_change_summary"' not in res.data
|
||||
|
||||
res = client.get(url_for("tags.form_tag_edit", uuid=tag_uuid))
|
||||
assert res.status_code == 200
|
||||
assert b'id="ai-llm"' not in res.data
|
||||
assert b'llm_intent' not in res.data
|
||||
|
||||
# 4. Add-watch page - with no "what matters" intent box there is nothing to choose
|
||||
# between, so element selection is always on and the opt-in checkbox is not rendered.
|
||||
res = client.get(url_for('add_watch_ui.add_watch_ui_index'))
|
||||
|
||||
Reference in New Issue
Block a user