mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-02-10 21:44:42 +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.
32 lines
888 B
Ruby
32 lines
888 B
Ruby
# frozen_string_literal: true
|
|
class ConvertAiPersonasCommandsToJson < ActiveRecord::Migration[7.0]
|
|
def up
|
|
# this all may be a bit surprising, but interestingly this makes all our backend code
|
|
# cross compatible
|
|
# upgrading ["a", "b", "c"] to json simply works cause in both cases
|
|
# rails will cast to a string array and all code simply expectes a string array
|
|
#
|
|
# this change was made so we can also start storing parameters with the commands
|
|
execute <<~SQL
|
|
ALTER TABLE ai_personas
|
|
ALTER COLUMN commands DROP DEFAULT
|
|
SQL
|
|
|
|
execute <<~SQL
|
|
ALTER TABLE ai_personas
|
|
ALTER COLUMN commands
|
|
TYPE json USING array_to_json(commands)
|
|
SQL
|
|
|
|
execute <<~SQL
|
|
ALTER TABLE ai_personas
|
|
ALTER COLUMN commands
|
|
SET DEFAULT '[]'::json
|
|
SQL
|
|
end
|
|
|
|
def down
|
|
raise ActiveRecord::IrreversibleMigration
|
|
end
|
|
end
|