mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 02:05:37 +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.
15 lines
239 B
Ruby
Vendored
15 lines
239 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module DiscourseAi
|
|
module TestHelpers
|
|
class FakeExternalAgent < DiscourseAi::Agents::Agent
|
|
def tools
|
|
[]
|
|
end
|
|
|
|
def system_prompt
|
|
"Test agent"
|
|
end
|
|
end
|
|
end
|
|
end
|