| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: MxChat |
| 4 | 4 | * Plugin URI: https://mxchat.ai/ |
| 5 | 5 | * Description: AI chatbot for WordPress with OpenAI, Claude, xAI, DeepSeek, live agent, PDF uploads, WooCommerce, and training on website data. |
| 6 | - * Version: 3.2.3 | |
| 6 | + * Version: 3.1.8 | |
| 7 | 7 | * Author: MxChat |
| 8 | 8 | * Author URI: https://mxchat.ai |
| 9 | 9 | * License: GPLv2 or later |
| 10 | 10 | * License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| @@ -608,54 +608,8 @@ | ||
| 608 | 608 | update_option('mxchat_content_type_migration_version', '2.5.6'); |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | /** |
| 612 | - * 3.2.3: Add embedding_model column to KB and intent tables so we can detect | |
| 613 | - * when the active embedding model is changed while content is already embedded. | |
| 614 | - */ | |
| 615 | -function mxchat_add_embedding_model_columns() { | |
| 616 | - global $wpdb; | |
| 617 | - | |
| 618 | - $migration_version = get_option('mxchat_embedding_model_migration_version', '0'); | |
| 619 | - if (version_compare($migration_version, '3.2.3', '>=')) { | |
| 620 | - return; | |
| 621 | - } | |
| 622 | - | |
| 623 | - $tables = array( | |
| 624 | - $wpdb->prefix . 'mxchat_system_prompt_content', | |
| 625 | - $wpdb->prefix . 'mxchat_intents', | |
| 626 | - $wpdb->prefix . 'mxchat_intent_phrases', | |
| 627 | - ); | |
| 628 | - | |
| 629 | - foreach ($tables as $table) { | |
| 630 | - if ($wpdb->get_var("SHOW TABLES LIKE '{$table}'") !== $table) { | |
| 631 | - continue; | |
| 632 | - } | |
| 633 | - $col_exists = $wpdb->get_results("SHOW COLUMNS FROM {$table} LIKE 'embedding_model'"); | |
| 634 | - if (empty($col_exists)) { | |
| 635 | - $wpdb->query("ALTER TABLE {$table} ADD COLUMN embedding_model VARCHAR(64) DEFAULT NULL"); | |
| 636 | - } | |
| 637 | - } | |
| 638 | - | |
| 639 | - // Best-effort backfill: if any existing content lacks a stamped model, assume | |
| 640 | - // it was embedded with whatever model is currently selected. This is the | |
| 641 | - // safest assumption for installations upgrading to 3.2.3 — if it was wrong | |
| 642 | - // already, the mismatch detection will surface it on the next switch. | |
| 643 | - $options = get_option('mxchat_options', array()); | |
| 644 | - $current_model = $options['embedding_model'] ?? 'text-embedding-ada-002'; | |
| 645 | - | |
| 646 | - if (get_option('mxchat_active_embedding_model', '') === '') { | |
| 647 | - $kb_table = $wpdb->prefix . 'mxchat_system_prompt_content'; | |
| 648 | - $kb_count = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$kb_table}"); | |
| 649 | - if ($kb_count > 0) { | |
| 650 | - update_option('mxchat_active_embedding_model', $current_model, false); | |
| 651 | - } | |
| 652 | - } | |
| 653 | - | |
| 654 | - update_option('mxchat_embedding_model_migration_version', '3.2.3'); | |
| 655 | -} | |
| 656 | - | |
| 657 | -/** | |
| 658 | 612 | * 2.5.2: Create queue processing tables for reliable background processing |
| 659 | 613 | */ |
| 660 | 614 | function mxchat_create_queue_tables() { |
| 661 | 615 | global $wpdb; |
| @@ -864,9 +818,8 @@ | ||
| 864 | 818 | embedding_vector LONGTEXT, |
| 865 | 819 | source_url TEXT DEFAULT NULL, |
| 866 | 820 | role_restriction VARCHAR(50) DEFAULT 'public', |
| 867 | 821 | content_type VARCHAR(50) DEFAULT 'content', |
| 868 | - embedding_model VARCHAR(64) DEFAULT NULL, | |
| 869 | 822 | timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, |
| 870 | 823 | PRIMARY KEY (id), |
| 871 | 824 | KEY content_type (content_type) |
| 872 | 825 | ) $charset_collate;"; |
| @@ -881,9 +834,8 @@ | ||
| 881 | 834 | callback_function VARCHAR(255) NOT NULL, |
| 882 | 835 | similarity_threshold FLOAT DEFAULT 0.85, |
| 883 | 836 | enabled TINYINT(1) NOT NULL DEFAULT 1, |
| 884 | 837 | enabled_bots LONGTEXT DEFAULT NULL, |
| 885 | - embedding_model VARCHAR(64) DEFAULT NULL, | |
| 886 | 838 | PRIMARY KEY (id) |
| 887 | 839 | ) $charset_collate;"; |
| 888 | 840 | |
| 889 | 841 | // Individual Intent Phrases Table - each phrase gets its own embedding vector |
| @@ -892,9 +844,8 @@ | ||
| 892 | 844 | id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
| 893 | 845 | intent_id BIGINT(20) UNSIGNED NOT NULL, |
| 894 | 846 | phrase TEXT NOT NULL, |
| 895 | 847 | embedding_vector LONGTEXT NOT NULL, |
| 896 | - embedding_model VARCHAR(64) DEFAULT NULL, | |
| 897 | 848 | created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL, |
| 898 | 849 | PRIMARY KEY (id), |
| 899 | 850 | KEY intent_id (intent_id) |
| 900 | 851 | ) $charset_collate;"; |
| @@ -961,11 +912,8 @@ | ||
| 961 | 912 | |
| 962 | 913 | // Run migration for existing installations |
| 963 | 914 | mxchat_migrate_pinecone_roles_add_bot_id(); |
| 964 | 915 | |
| 965 | - // 3.2.3: Add embedding_model column to KB and intent tables | |
| 966 | - mxchat_add_embedding_model_columns(); | |
| 967 | - | |
| 968 | 916 | // Setup cron jobs |
| 969 | 917 | mxchat_setup_cron_jobs(); |
| 970 | 918 | |
| 971 | 919 | // Update version |
| @@ -1138,13 +1086,8 @@ | ||
| 1138 | 1086 | // 3.1.7: Clean up stale shared session email/name entries |
| 1139 | 1087 | if (version_compare($current_version, '3.1.7', '<')) { |
| 1140 | 1088 | delete_option('mxchat_email_null'); |
| 1141 | 1089 | delete_option('mxchat_name_null'); |
| 1142 | - } | |
| 1143 | - | |
| 1144 | - // 3.2.3: Add embedding_model tracking columns and backfill active model | |
| 1145 | - if (version_compare($current_version, '3.2.3', '<')) { | |
| 1146 | - mxchat_add_embedding_model_columns(); | |
| 1147 | 1090 | } |
| 1148 | 1091 | |
| 1149 | 1092 | // Run full activation to ensure everything is up to date |
| 1150 | 1093 | mxchat_activate(); |