PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 8.8.1
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v8.8.1
8.8.1 8.8.0 8.7.9 8.7.8 8.7.7 8.7.6 8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.9 8.6.8 8.6.7 8.6.6 8.6.5 8.6.4 8.6.2 8.6.1 8.6.0 8.5.9 8.5.8 8.5.7 8.5.6 All 537 releases
← All changes | includes/admin/templates/rag.php +160 -6 8.6.0 → 8.8.1 View file →
@@ -18,8 +18,9 @@
18 18
19 19
20 20 <h2 class="nav-tab-wrapper">
21 21 <a href="#qcld-rag-settings-tab" class="nav-tab nav-tab-active"> Setting options</a>
22 + <a href="#qcld-rag-settings-sql" class="nav-tab">RAG from DB Tables</a>
22 23 <a href="#rag-sync" class="nav-tab">Sync and upload options</a>
23 24 <a href="#rag-sources" class="nav-tab">Manage Sources</a>
24 25 <a href="#rag-database" class="nav-tab">KnowledgeBase Database</a>
25 26 </h2>
@@ -25,10 +26,10 @@
25 26 </h2>
26 27
27 28 <div id="qcld-rag-settings-tab" class="qcld-tab-content active">
28 29 <!-- ===========================
29 - EMBEDDING SOURCE OPTIONS
30 - ============================ -->
30 + EMBEDDING SOURCE OPTIONS
31 + ============================ -->
31 32 <div class="wrap">
32 33 <h3>Choose Data Sources to Embed</h3>
33 34
34 35 <div class="mb-3">
@@ -80,9 +81,18 @@
80 81 </div>
81 82 </div>
82 83
83 84 </div>
84 - <!-- ===========================
85 + <div class="wrap">
86 + <h3>Sync Settings</h3>
87 +
88 + <div class="mb-3">
89 + <input type="checkbox" id="rag_auto_sync_enabled" class="rag_auto_sync_enabled" <?php checked(get_option('rag_auto_sync_enabled'), '1'); ?>>
90 + <label for="rag_auto_sync_enabled"><strong>Enable Auto Sync (on Save)</strong></label>
91 + <p class="description">Automatically update embeddings when a post or product is saved/updated.</p>
92 + </div>
93 + </div>
94 + <!-- ===========================
85 95 EXECUTION BUTTON
86 96 ============================ -->
87 97 <div class="wrap my-4">
88 98 <p style="color: red"> <b><?php esc_html_e('Please connect to an AI service like OpenAI or Gemini before embedding. ', 'chatbot'); ?></b><b><a target="_blank" href="https://wpbot.pro/docs/knowledgebase/how-to-use-an-embedded-vector-database-and-rag-to-get-customized-responses-from-ai/"><?php esc_html_e('Check this Tutorial for more details.', 'chatbot'); ?></a></b></p>
@@ -112,10 +122,154 @@
112 122 <div class="wrap">
113 123 <button class="qcld-btn-primary" id="save_rag_setting">Save Settings</button>
114 124 </div>
115 125 </div>
126 + <div id="qcld-rag-settings-sql" class="qcld-tab-content">
127 +
128 + <div class="wrap">
129 + <h3>Choose Data Sources to Embed</h3>
130 + <?php if ( $wpchatbot_license_valid != 'master' && $wpchatbot_license_valid != 'professional'): ?>
131 + <div class="wrap">
132 + <div style="background-color: #fee; border: 1px solid #c33; padding: 15px; margin: 20px 0; border-radius: 4px;">
133 + <p style="color: #c33; font-weight: bold; margin: 0; font-size: 14px;">
134 + These options are available with the WPBot Pro <a href="https://www.wpbot.pro/pricing/" target="_blank" style="color: #c33; text-decoration: underline;">Professional</a> and <a href="https://www.wpbot.pro/pricing/" target="_blank" style="color: #c33; text-decoration: underline;">Master</a> Licenses
135 + </p>
136 + </div>
137 + </div>
138 + <?php endif; ?>
139 + <div class="mb-3" style="<?php if ( $wpchatbot_license_valid != 'master' && $wpchatbot_license_valid != 'professional'){ echo 'opacity:0.5; pointer-events:none;'; } ?>">
140 + <input type="checkbox" id="rag_embed_sql" checked disabled <?php checked(get_option('rag_embed_sql'), '1'); ?>>
141 + <label for="rag_embed_sql">Database Table (SQL)</label>
142 + <div id="rag_sql_options" style="">
143 + <table id="rag_sql_tables_list" class="wp-list-table widefat striped" style="max-width: 600px; margin-bottom: 10px;">
144 + <thead>
145 + <tr>
146 + <th>Table Name</th>
147 + <th>Table Field(s)</th>
148 + <th>Actions</th>
149 + </tr>
150 + </thead>
151 + <tbody>
152 + <?php
153 + $sql_tables = get_option('rag_sql_tables', []);
154 + if (!is_array($sql_tables) && !empty($sql_tables)) {
155 + $sql_tables = json_decode($sql_tables, true);
156 + }
157 +
158 + if (empty($sql_tables)) {
159 + $table_name = get_option('rag_sql_table_name', '');
160 + $table_field = get_option('rag_sql_table_field', '');
161 + if ($table_name && $table_field) {
162 + $sql_tables[] = ['table_name' => $table_name, 'table_field' => $table_field];
163 + }
164 + }
116 165
166 + if (!empty($sql_tables)) {
167 + foreach ($sql_tables as $table) {
168 + ?>
169 + <tr>
170 + <td><input type="text" name="rag_sql_table_name[]" value="<?php echo esc_attr($table['table_name']); ?>" class="regular-text" style="width:100%;"></td>
171 + <td><input type="text" name="rag_sql_table_field[]" value="<?php echo esc_attr($table['table_field']); ?>" class="regular-text" style="width:100%;"></td>
172 + <td><button type="button" class="button button-link-delete rag_sql_remove_table">Remove</button></td>
173 + </tr>
174 + <?php
175 + }
176 + } else {
177 + ?>
178 + <tr>
179 + <td><input type="text" name="rag_sql_table_name[]" value="" placeholder="e.g. wp_users" class="regular-text" style="width:100%;"></td>
180 + <td><input type="text" name="rag_sql_table_field[]" value="" placeholder="e.g. user_email" class="regular-text" style="width:100%;"></td>
181 + <td><button type="button" class="button button-link-delete rag_sql_remove_table">Remove</button></td>
182 + </tr>
183 + <?php
184 + }
185 + ?>
186 + </tbody>
187 + </table>
188 + <button type="button" class="button button-primary" id="rag_sql_add_table">Add New Table</button>
189 + <button type="button" class="button button-secondary" id="sql_instruction" style="margin-left: 5px;">View Available SQL Tables & Fields</button>
190 + <p class="description">Add multiple tables and fields. Separate multiple fields in the same table with commas. Click "Create Missing Tables" to generate empty tables in the database if they don't exist.</p>
191 + </div>
192 + <!-- New Section for Google Sheets to SQL Sync -->
193 + <div id="rag_sql_sheets_section" style="display:block; margin-top: 20px; margin-left: 20px; padding: 15px; border: 1px solid #ccc; background: #f9f9f9;">
194 + <h4>Google Sheets & CSV Database Sync</h4>
195 + <p class="description">Directly import Google Sheets or upload CSV data into SQL tables for Text-to-SQL querying.</p>
196 +
197 + <div style="margin-bottom: 15px;">
198 + <label style="display:block; font-weight:bold; margin-bottom:5px;">Import via Google Sheet URL:</label>
199 + <input type="text" id="rag_sql_sheet_url_input" placeholder="Enter Google Sheet or CSV URL" class="regular-text" style="width: 60%; margin-right: 5px;">
200 + <button type="button" class="button button-primary" id="rag_sql_import_sheet">Import URL to SQL</button>
201 + </div>
117 202
203 + <div style="margin-bottom: 15px;">
204 + <label style="display:block; font-weight:bold; margin-bottom:5px;">Upload a Local CSV File:</label>
205 + <input type="file" id="rag_sql_csv_file_input" accept=".csv" style="margin-right: 5px;">
206 + <button type="button" class="button button-primary" id="rag_sql_upload_csv">Upload CSV to SQL</button>
207 + </div>
208 +
209 + <hr style="margin: 15px 0;">
210 + <p>Sync all your previously uploaded sheets into SQL tables:</p>
211 + <button type="button" class="button button-secondary" id="rag_sql_sync_existing_sheets">Sync Existing Sheets to SQL</button>
212 +
213 + <div id="rag_sql_sync_status" style="margin-top: 10px; font-weight: bold;"></div>
214 + </div>
215 + </div>
216 + <br><br>
217 + <div class="mb-3" style="<?php if ( $wpchatbot_license_valid != 'master' && $wpchatbot_license_valid != 'professional'){ echo 'opacity:0.5; pointer-events:none;'; } ?> ">
218 + <input type="checkbox" id="rag_sql_auto_sync_enabled" <?php checked(get_option('rag_sql_auto_sync_enabled'), '1'); ?>>
219 + <label for="rag_sql_auto_sync_enabled"><strong>Enable Auto Sync (on Save)</strong></label>
220 + <p class="description">Automatically update embeddings </p>
221 + </div>
222 + <hr>
223 + <?php
224 + $sql_sync_interval = get_option('rag_sql_sync_interval', 'daily');
225 + $sql_interval_labels = [
226 + 'hourly' => '(Hourly)',
227 + 'twicedaily' => '(Twice Daily)',
228 + 'daily' => '(Daily)',
229 + 'weekly' => '(Weekly)',
230 + ];
231 + $sql_interval_desc = [
232 + 'hourly' => 'once per hour',
233 + 'twicedaily' => 'twice per day',
234 + 'daily' => 'once per day',
235 + 'weekly' => 'once per week',
236 + ];
237 + $sql_current_label = $sql_interval_labels[$sql_sync_interval] ?? '(Daily)';
238 + $sql_current_desc = $sql_interval_desc[$sql_sync_interval] ?? 'once per day';
239 + ?>
240 +
241 + <div class="mb-3" style="<?php if ( $wpchatbot_license_valid != 'master' && $wpchatbot_license_valid != 'professional'){ echo 'opacity:0.5; pointer-events:none;'; } ?>">
242 + <label for="rag_sql_sync_interval"><strong>Sync Interval:</strong></label>
243 + <select id="rag_sql_sync_interval">
244 + <option value="five_minutes" <?php selected(get_option('rag_sql_sync_interval'), 'five_minutes'); ?>>Every 5 Minutes</option>
245 + <option value="hourly" <?php selected(get_option('rag_sql_sync_interval'), 'hourly'); ?>>Hourly</option>
246 + <option value="twicedaily" <?php selected(get_option('rag_sql_sync_interval'), 'twicedaily'); ?>>Twice Daily</option>
247 + <option value="daily" <?php selected(get_option('rag_sql_sync_interval', 'daily'), 'daily'); ?>>Once Daily</option>
248 + <option value="weekly" <?php selected(get_option('rag_sql_sync_interval'), 'weekly'); ?>>Weekly</option>
249 + </select>
250 + <p class="description">Choose how often to run the automated synchronization.</p>
251 + </div>
252 +
253 + </div>
254 +
255 + <div class="wrap my-4" style="<?php if ( $wpchatbot_license_valid != 'master' && $wpchatbot_license_valid != 'professional'){ echo 'opacity:0.5; pointer-events:none;'; } ?>">
256 + <button type="button" id="rag_embed_sql_btn" class="button button-primary">Embed Selected Database Data</button>
257 +
258 + <div id="rag_sql_progress_container" style="display:none; margin-top: 20px;">
259 + <div class="progress" style="height: 25px; background-color: #f1f1f1; border-radius: 5px; overflow: hidden;">
260 + <div id="rag_sql_progress_bar" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%; height: 100%; background-color: #007bff; transition: width 0.3s ease;"></div>
261 + </div>
262 + <p id="rag_sql_progress_status" style="margin-top: 10px; font-weight: bold;"></p>
263 + </div>
264 + </div>
265 +
266 + <!-- SAVE SETTINGS BUTTON -->
267 + <div class="wrap" style="<?php if ( $wpchatbot_license_valid != 'master' && $wpchatbot_license_valid != 'professional'){ echo 'opacity:0.5; pointer-events:none;'; } ?>">
268 + <button class="qcld-btn-primary" id="save_rag_setting">Save Settings</button>
269 + </div>
270 + </div>
271 +
118 272 <div id="rag-sync" class="qcld-tab-content">
119 273 <?php if ( $wpchatbot_license_valid != 'master' && $wpchatbot_license_valid != 'professional'): ?>
120 274 <div class="wrap">
121 275 <div style="background-color: #fee; border: 1px solid #c33; padding: 15px; margin: 20px 0; border-radius: 4px;">
@@ -136,10 +290,10 @@
136 290 <div class="wrap">
137 291 <h3>Sync Settings</h3>
138 292
139 293 <div class="mb-3">
140 - <input type="checkbox" id="rag_auto_sync_enabled" <?php checked(get_option('rag_auto_sync_enabled'), '1'); ?>>
141 - <label for="rag_auto_sync_enabled"><strong>Enable Auto Sync (on Save)</strong></label>
294 + <input type="checkbox" id="rag_auto_sync_enabled_tab" class="rag_auto_sync_enabled" <?php checked(get_option('rag_auto_sync_enabled'), '1'); ?>>
295 + <label for="rag_auto_sync_enabled_tab"><strong>Enable Auto Sync (on Save)</strong></label>
142 296 <p class="description">Automatically update embeddings when a post or product is saved/updated.</p>
143 297 </div>
144 298 <hr>
145 299 <?php
@@ -841,5 +995,5 @@
841 995 // Default to first tab if no sub-tab specified
842 996 $('.nav-tab-wrapper a').first().trigger('click');
843 997 }
844 998 });
845 -</script>
999 +</script>