discourse-ai/app/controllers/discourse_ai/admin
Sam 9f2a4094f5
FEATURE: persona/tool import and export (#1450)
Introduces import/export feature for tools and personas.

Uploads are omitted for now, and will be added in a future PR 

*   **Backend:**
    *   Adds `import` and `export` actions to `Admin::AiPersonasController` and `Admin::AiToolsController`.
    *   Introduces `DiscourseAi::PersonaExporter` and `DiscourseAi::PersonaImporter` services to manage JSON serialization and deserialization.
    *   The export format for a persona embeds its associated custom tools. To ensure portability, `AiTool` references are serialized using their `tool_name` rather than their internal database `id`.
    *   The import logic detects conflicts by name. A `force=true` parameter can be passed to overwrite existing records.

*   **Frontend:**
    *   `AiPersonaListEditor` and `AiToolListEditor` components now include an "Import" button that handles file selection and POSTs the JSON data to the respective `import` endpoint.
    *   `AiPersonaEditorForm` and `AiToolEditorForm` components feature an "Export" button that triggers a download of the serialized record.
    *   Handles import conflicts (HTTP `409` for tools, `422` for personas) by showing a `dialog.confirm` prompt to allow the user to force an overwrite.

*   **Testing:**
    *   Adds comprehensive request specs for the new controller actions (`#import`, `#export`).
    *   Includes unit specs for the `PersonaExporter` and `PersonaImporter` services.
* Persona import and export implemented
2025-06-24 12:41:10 +10:00
..
ai_embeddings_controller.rb DEV: Log AI related configuration to staff action log (#1416) 2025-06-12 12:39:58 -07:00
ai_features_controller.rb DEV: Use a PORO to represent modules/features. (#1421) 2025-06-10 14:37:53 -03:00
ai_llm_quotas_controller.rb FEATURE: llm quotas (#1047) 2025-01-14 15:54:09 +11:00
ai_llms_controller.rb DEV: Log AI related configuration to staff action log (#1416) 2025-06-12 12:39:58 -07:00
ai_personas_controller.rb FEATURE: persona/tool import and export (#1450) 2025-06-24 12:41:10 +10:00
ai_spam_controller.rb DEV: Log AI related configuration to staff action log (#1416) 2025-06-12 12:39:58 -07:00
ai_tools_controller.rb FEATURE: persona/tool import and export (#1450) 2025-06-24 12:41:10 +10:00
ai_usage_controller.rb UX: Improve rough edges of AI usage page (#1014) 2024-12-12 08:55:24 +11:00
dashboard_controller.rb FEATURE: Expose sentiment classifications via the admin dashboard. (#284) 2023-11-08 10:50:37 -03:00
rag_document_fragments_controller.rb FEATURE: Native PDF support (#1127) 2025-02-18 09:22:57 +11:00