[mod] plugin: AI tab only when activated, user API key, grounding on
Three changes to the ai_summary plugin: - The *AI Summary* preferences tab is only rendered when the plugin is activated in settings.yml. An instance that does not offer AI summaries no longer shows an AI tab at all. The gate is the administrator setting, not the user opt-out, because the per user on/off switch lives inside that tab -- hiding it on opt-out would leave no way to opt back in. - Users can configure an API key for their own LLM server (ai_summary_api_key). The administrator key is still only sent to base_url and the user key only to a server the user configured, so neither key can be captured through the other. The setting is marked secret: credentials are excluded from the preferences URL, which users copy around to transfer or share their preferences. - Grounding summaries on the search results is now the default; the extra cost of the longer prompt is moderate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
ce400f993c
commit
8edc368752
+13
-2
@@ -49,10 +49,14 @@ class ValidationException(Exception):
|
||||
class Setting:
|
||||
"""Base class of user settings"""
|
||||
|
||||
def __init__(self, default_value: t.Any, locked: bool = False):
|
||||
def __init__(self, default_value: t.Any, locked: bool = False, secret: bool = False):
|
||||
super().__init__()
|
||||
self.value: t.Any = default_value
|
||||
self.locked: bool = locked
|
||||
self.secret: bool = secret
|
||||
"""The value is a credential: it is not included in the preferences URL
|
||||
(:py:obj:`Preferences.get_as_url_params`), which users copy around to
|
||||
transfer or share their preferences."""
|
||||
|
||||
def parse(self, data: str):
|
||||
"""Parse ``data`` and store the result at ``self.value``
|
||||
@@ -468,6 +472,13 @@ class Preferences:
|
||||
"",
|
||||
locked="ai_summary_server" in self.cfg.lock,
|
||||
),
|
||||
'ai_summary_api_key': StringSetting(
|
||||
"",
|
||||
locked="ai_summary_api_key" in self.cfg.lock,
|
||||
# a user's API key is only sent to a server the user configured
|
||||
# themselves, and it is never part of the preferences URL
|
||||
secret=True,
|
||||
),
|
||||
'ai_summary_model': StringSetting(
|
||||
"",
|
||||
locked="ai_summary_model" in self.cfg.lock,
|
||||
@@ -512,7 +523,7 @@ class Preferences:
|
||||
"""Return preferences as URL parameters"""
|
||||
settings_kv = {}
|
||||
for k, v in self.key_value_settings.items():
|
||||
if v.locked:
|
||||
if v.locked or v.secret:
|
||||
continue
|
||||
if isinstance(v, MultipleChoiceSetting):
|
||||
settings_kv[k] = ','.join(v.get_value())
|
||||
|
||||
Reference in New Issue
Block a user