mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-03-06 17:30:20 +00:00
Personas now support providing options for commands. This PR introduces a single option "base_query" for the SearchCommand. When supplied all searches the persona will perform will also include the pre-supplied filter. This can allow personas to search a subset of the forum (such as documentation) This system is extensible we can add options to any command trivially.
34 lines
567 B
Ruby
34 lines
567 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AiCommandSerializer < ApplicationSerializer
|
|
attributes :options, :id, :name, :help
|
|
|
|
def include_options?
|
|
object.options.present?
|
|
end
|
|
|
|
def id
|
|
object.to_s.split("::").last
|
|
end
|
|
|
|
def name
|
|
object.name.humanize.titleize
|
|
end
|
|
|
|
def help
|
|
object.help
|
|
end
|
|
|
|
def options
|
|
options = {}
|
|
object.options.each do |option|
|
|
options[option.name] = {
|
|
name: option.localized_name,
|
|
description: option.localized_description,
|
|
type: option.type,
|
|
}
|
|
end
|
|
options
|
|
end
|
|
end
|