-
-
Notifications
You must be signed in to change notification settings - Fork 263
Description
Can we use the Gemini API to make relevant resources available to the editor when creating an FAQ or answering open questions?
Feature Request: AI-Powered Editorial Assistant via Gemini API (Research & Grounding)
Description
This feature integrates the Google Gemini API to help editors create and moderate FAQ entries. It focuses on "Grounding with Google Search" to provide editors with verified sources and up-to-date information directly within the phpMyFAQ admin interface.
The Problem
Editors often need external research to ensure accuracy when answering questions or drafting new FAQ articles. This currently requires switching between tabs and searching for reliable sources manually. Summarizing complex information into a concise FAQ format is also time-consuming.
Proposed Solution: The "Research & Draft" Modal
A new AI-powered interface within the Admin area (specifically in Edit FAQ and Open Questions) will provide:
1. Research & Verification (Grounding)
- Source Suggestion: The Gemini Search Tool suggests 3–5 relevant web link sources based on the question or title for further research.
- AI-Generated Draft Summary: Based on the retrieved search results, a factual summary is generated as a starting point for the FAQ article, ensuring the draft is backed by real data.
- Link Handling: All suggested links must open in a new browser tab (_target="blank") to ensure compatibility with sites blocking IFrames (X-Frame-Options). This allows editors to use a side-by-side window layout for efficient fact-checking while the admin panel remains open.
2. Contextual Drafting & Jodit Integration
- Modal Interface: A central Modal displays the search results (links) and the generated summary.
- Transfer to Editor: Clicking a "Transfer to Editor" button injects the AI-generated draft directly into the Jodit editor instance, and the modal closes automatically.
3. Mandatory Review Workflow (Safety First)
To prevent publishing unverified AI content, a locking mechanism for activation (active = 'yes') is implemented:
- Edit Detection: If AI content is imported into the editor, the system sets an internal "*AI-generated" flag. The "Activate & Save" button remains disabled by default.
- Approval Requirements: Activation is only possible if:
- The editor manually edits the text within the Jodit editor (detected via onInput or change events) OR
- The editor explicitly checks a mandatory checkbox: "I have reviewed the AI-generated content and accept it without further changes."
- Backend Validation: The system verifies these conditions before allowing the FAQ to be set to "active".
4. Transparency & SEO (Frontend)
- Metadata Flag: Articles created with AI assistance should have a flag (e.g., ai_assisted = true).
- Frontend Label: A disclaimer is displayed to users: "This article was drafted with AI assistance and editorially verified."
Workflow Diagram
graph TD
%% Entry Points
A1((Open Question)) --> B[Button: Research with Gemini]
A2((New FAQ)) --> B
%% AI & Modal Process
B --> C[Gemini API: Search Grounding <br/>based on Title/Question]
C --> D{Open Modal}
D --> E[Display: Source Links & Draft Summary]
E --> F[Link Click: Opens New Tab <br/>target='_blank']
%% Transfer Phase
F --> G[Button: Transfer to Editor]
G --> H[Close Modal & <br/>Insert text into Jodit Editor]
%% Safety Logic
H --> I[Status: 'Activate' Button Locked]
I --> J{Editorial Review}
J -- Text edited in Jodit --> K[Release Activation]
J -- Text unchanged --> L[Check: 'Accept AI content <br/>without changes']
L --> K
K --> M[Save & Activate FAQ]
M --> N[Frontend: FAQ Live <br/>with AI Disclaimer]
%% Styling
style D fill:#4285F4,color:#fff
style I fill:#f96,stroke:#333,stroke-width:2px
style K fill:#d5e8d4,stroke:#82b366
style L fill:#fff2cc,stroke:#d6b656
Alignment with Content Status Workflow
This AI assistant is designed to integrate with the proposed Editorial Workflow (Draft, Review, Published) #3831 .
- Automatic Status Assignment: When AI content is transferred, the FAQ status is automatically set to
Draftor a new specializedAI-Reviewsub-status. - Safety Lock as Status Transition: The mandatory review (editing or checkbox) serves as a prerequisite for the status transition from
DrafttoRevieworPublished. - Compliance: This ensures that even in regulated environments, AI-assisted content never bypasses human oversight, fulfilling the requirement that "status changes are permission-checked."
Technical Implementation Details
- API: Integration of the Google Gemini API (supporting the Free Tier).
- Settings: Central configuration for the Gemini API Key in the system settings.
- Jodit API: Use Jodit’s API to insert content (e.g., editor.value = aiContent;) and track the "unedit" state of the editor.
- Security: Use rel="noopener noreferrer" for all external research links to protect the admin session.
- Prompt Engineering: Focus the system prompt on factual grounding, requiring the inclusion of source URLs.
Use Case Example
- An editor starts a new FAQ: "How to configure PHP 8.5 for phpMyFAQ?"
- Clicks "Research with Gemini".
- A Modal opens with links to official PHP docs and a drafted guide.
- Editor checks the links in new tabs, clicks "Transfer to Editor".
- The editor tweaks a few sentences in Jodit. The "Activate" button unlocks.
- The editor clicks "Activate & Save".
Why this is important
This workflow protects the knowledge base's integrity. It uses AI as a tool for the editor while maintaining strict human oversight and quality control.