mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-24 04:36:33 +08:00
This commit introduces `DiscourseAi.register_feature` as the public API for other plugins to register AI-powered features. Previously, plugins had to manually register with `DiscoursePluginRegistry`, define their own agent site setting in `settings.yml`, create their own `EnumSiteSetting` subclass for the agent enum, register the site setting area, and assign settings to that area. This was a lot of boilerplate that every plugin would need to duplicate. This commit consolidates all of that into a single `DiscourseAi.register_feature` call that handles: 1. Auto-defining the `<module>_<feature>_agent` site setting with the correct enum, `depends_on`, and `depends_behavior` configuration 2. Registering the `ai-features/<module_name>` site setting area so the admin edit page can load the settings 3. Assigning both the generated agent setting and the `enabled_by_setting` to that area 4. Registering the feature in the `DiscoursePluginRegistry` external AI features registry The data-explorer plugin is updated to use the new API, which lets it drop its custom `AiAgentEnumerator` class, the manual `data_explorer_query_generation_agent` setting definition in `settings.yml`, and the manual area registration and assignment code.
14 lines
318 B
YAML
Vendored
14 lines
318 B
YAML
Vendored
discourse_data_explorer:
|
|
data_explorer_enabled:
|
|
default: false
|
|
client: true
|
|
data_explorer_ai_queries_enabled:
|
|
default: false
|
|
client: true
|
|
depends_on:
|
|
- discourse_ai_enabled
|
|
depends_behavior: hidden
|
|
data_explorer_query_result_limit:
|
|
default: 1000
|
|
hidden: true
|
|
max: 10000
|