mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-02-07 12:08:13 +00:00
a03bc6ddec
This allows users to share a static page of an AI conversation with the rest of the world. By default this feature is disabled, it is enabled by turning on ai_bot_allow_public_sharing via site settings Precautions are taken when sharing 1. We make a carbonite copy 2. We minimize work generating page 3. We limit to 100 interactions 4. Many security checks - including disallowing if there is a mix of users in the PM. * Bonus commit, large PRs like this PR did not work with github tool large objects would destroy context Co-authored-by: Martin Brennan <martin@discourse.org>
28 lines
908 B
Ruby
28 lines
908 B
Ruby
# frozen_string_literal: true
|
|
|
|
class AddSharedAiConversations < ActiveRecord::Migration[7.0]
|
|
def up
|
|
create_table :shared_ai_conversations do |t|
|
|
t.integer :user_id, null: false
|
|
t.integer :target_id, null: false
|
|
t.string :target_type, null: false, max_length: 100
|
|
t.string :title, null: false, max_length: 1024
|
|
t.string :llm_name, null: false, max_length: 1024
|
|
t.jsonb :context, null: false
|
|
t.string :share_key, null: false, index: { unique: true }
|
|
t.string :excerpt, null: false, max_length: 10_000
|
|
t.timestamps
|
|
end
|
|
|
|
add_index :shared_ai_conversations, %i[target_id target_type], unique: true
|
|
add_index :shared_ai_conversations,
|
|
%i[user_id target_id target_type],
|
|
unique: true,
|
|
name: "idx_shared_ai_conversations_user_target"
|
|
end
|
|
|
|
def down
|
|
drop_table :shared_ai_conversations
|
|
end
|
|
end
|