Plugin Directory

Changeset 3453818


Ignore:
Timestamp:
02/04/2026 01:14:52 PM (8 weeks ago)
Author:
samuelsilvapt
Message:

AI Search - v1.18.0

Location:
ai-search
Files:
42 added
4 edited

Legend:

Unmodified
Added
Removed
  • ai-search/trunk/admin/views/components/threshold-slider.php

    r3447176 r3453818  
    33 * Reusable Similarity Threshold Slider Component
    44 *
    5  * @param float $current_value Current threshold value (0.5-1.0)
     5 * @param float $current_value Current threshold value (0.1-1.0)
    66 * @param string $context 'wizard' or 'settings' - determines styling and features
    77 */
     
    3131           id="similarity_threshold_display"
    3232           class="ai-search-threshold-slider"
    33            min="50"
     33           min="10"
    3434           max="100"
    3535           step="1"
     
    3838
    3939    <div class="ai-search-threshold-labels">
    40         <span><?php esc_html_e( '50% - Broad', 'ai-search' ); ?></span>
     40        <span><?php esc_html_e( '10% - Very Broad', 'ai-search' ); ?></span>
    4141        <span class="recommended"><?php esc_html_e( '65% Recommended', 'ai-search' ); ?></span>
    4242        <span><?php esc_html_e( '100% - Exact Match', 'ai-search' ); ?></span>
     
    6262        <p>
    6363            <strong><?php esc_html_e( 'Guidelines:', 'ai-search' ); ?></strong>
    64             <?php esc_html_e( '50-60% (Broad) | 60-70% (Balanced) | 70-80% (Precise) | 80%+ (Very Strict)', 'ai-search' ); ?>
     64            <?php esc_html_e( '10-30% (Very Broad) | 30-60% (Broad) | 60-70% (Balanced) | 70-80% (Precise) | 80%+ (Very Strict)', 'ai-search' ); ?>
    6565        </p>
    6666        <p style="font-size: 12px; color: #666;">
     
    9494    if (!icon || !label || !description || !indicator) return;
    9595
    96     if (thresholdValue < 0.60) {
     96    if (thresholdValue < 0.30) {
     97        icon.textContent = "<?php esc_html_e( 'VERY BROAD', 'ai-search' ); ?>";
     98        label.textContent = "<?php esc_html_e( 'Very Broad Search', 'ai-search' ); ?>";
     99        label.style.color = "#8B0000";
     100        description.textContent = "<?php esc_html_e( 'Returns almost everything, even loosely related content. Useful when semantic scores are generally low.', 'ai-search' ); ?>";
     101        indicator.style.borderLeftColor = "#8B0000";
     102        indicator.style.background = "#fff0f0";
     103    } else if (thresholdValue < 0.60) {
    97104        icon.textContent = "<?php esc_html_e( 'BROAD', 'ai-search' ); ?>";
    98105        label.textContent = "<?php esc_html_e( 'Broad Search', 'ai-search' ); ?>";
  • ai-search/trunk/admin/views/settings-general.php

    r3451586 r3453818  
    1010$service_token = get_option( 'ai_search_service_token', '' );
    1111$badge_public = get_option( 'ai_search_badge_public', false );
     12$openai_model = get_option( 'ai_search_openai_model', 'text-embedding-3-small' );
    1213
    1314// Handle connection check messages
     
    5859    update_option( 'ai_search_badge_public', isset( $_POST['badge_public'] ) && $_POST['badge_public'] === '1' );
    5960
     61    // Save OpenAI model selection
     62    $allowed_models = [ 'text-embedding-3-small', 'text-embedding-3-large' ];
     63    $selected_model = isset( $_POST['openai_model'] ) ? sanitize_text_field( $_POST['openai_model'] ) : 'text-embedding-3-small';
     64    if ( in_array( $selected_model, $allowed_models, true ) ) {
     65        update_option( 'ai_search_openai_model', $selected_model );
     66    }
     67
    6068    // Handle AI service registration
    6169    $service_client = new AI_Search_Service();
     
    7886    $service_token = get_option( 'ai_search_service_token', '' );
    7987    $badge_public = get_option( 'ai_search_badge_public', false );
     88    $openai_model = get_option( 'ai_search_openai_model', 'text-embedding-3-small' );
    8089}
    8190?>
     
    105114                <input type="text" id="api_key" name="api_key" value="<?php echo esc_attr( $api_key ); ?>" class="regular-text" />
    106115                <p class="description"><?php esc_html_e( 'Enter your OpenAI API key to use your own account for embeddings.', 'ai-search' ); ?></p>
     116            </td>
     117        </tr>
     118
     119        <tr id="openai-model-row" style="display: <?php echo ( $provider === 'openai' ? 'table-row' : 'none' ); ?>;">
     120            <th scope="row">
     121                <label for="openai_model"><?php esc_html_e( 'Embedding Model', 'ai-search' ); ?></label>
     122            </th>
     123            <td>
     124                <select id="openai_model" name="openai_model">
     125                    <option value="text-embedding-3-small" <?php selected( $openai_model, 'text-embedding-3-small' ); ?>><?php esc_html_e( 'text-embedding-3-small (Recommended)', 'ai-search' ); ?></option>
     126                    <option value="text-embedding-3-large" <?php selected( $openai_model, 'text-embedding-3-large' ); ?>><?php esc_html_e( 'text-embedding-3-large (Higher quality)', 'ai-search' ); ?></option>
     127                </select>
     128                <p class="description"><?php esc_html_e( 'The small model offers great performance at lower cost. The large model provides higher accuracy but costs more. Changing model requires regenerating all embeddings.', 'ai-search' ); ?></p>
    107129            </td>
    108130        </tr>
     
    145167function aiSearchToggleApiKey() {
    146168    var provider = document.getElementById("provider").value;
    147     document.getElementById("openai-key-row").style.display = (provider === "openai") ? "table-row" : "none";
     169    var isOpenAI = provider === "openai";
     170    document.getElementById("openai-key-row").style.display = isOpenAI ? "table-row" : "none";
     171    document.getElementById("openai-model-row").style.display = isOpenAI ? "table-row" : "none";
    148172    document.getElementById("service-status-row").style.display = (provider === "ai_service") ? "table-row" : "none";
    149173}
  • ai-search/trunk/ai-search.php

    r3451586 r3453818  
    33 * Plugin Name: AI Search
    44 * Description: Replaces the default search with an intelligent search system.
    5  * Version: 1.17.0
     5 * Version: 1.18.0
    66 * Author: Samuel Silva
    77 * Author URI: https://samuelsilva.pt
     
    1717
    1818// Define plugin constants
    19 define( 'AI_SEARCH_VERSION', '1.17.0' );
     19define( 'AI_SEARCH_VERSION', '1.18.0' );
    2020define( 'AI_SEARCH_PATH', plugin_dir_path( __FILE__ ) );
    2121define( 'AI_SEARCH_URL', plugin_dir_url( __FILE__ ) );
     
    2424// Load dependencies
    2525require_once AI_SEARCH_PATH . 'includes/class-ai-search-service.php';
     26require_once AI_SEARCH_PATH . 'includes/class-rest-api.php';
    2627require_once AI_SEARCH_PATH . 'admin/class-admin-manager.php';
    2728
     
    3940     * Plugin version.
    4041     */
    41     const VERSION = '1.16.0';
     42    const VERSION = '1.18.0';
    4243
    4344    /**
     
    101102
    102103        $this->register_hooks();
    103        
     104
     105        // Initialize REST API
     106        new AI_Search_REST_API();
     107
    104108        // Initialize admin interface if in admin area
    105109        if ( is_admin() ) {
     
    434438            'body'    => wp_json_encode([
    435439                'input' => $content,
    436                 'model' => 'text-embedding-ada-002',
     440                'model' => get_option( 'ai_search_openai_model', 'text-embedding-3-small' ),
    437441            ]),
    438442        ]);
     
    498502        if ( current_user_can( 'manage_options' ) && isset( $_GET['ai_threshold'] ) ) {
    499503            $threshold = floatval( $_GET['ai_threshold'] );
    500             $threshold = max( 0.5, min( 1.0, $threshold ) ); // Clamp between 0.5 and 1.0
     504            $threshold = max( 0.1, min( 1.0, $threshold ) ); // Clamp between 0.5 and 1.0
    501505        }
    502506
     
    772776        if ( current_user_can( 'manage_options' ) && isset( $_GET['ai_threshold'] ) ) {
    773777            $threshold = floatval( $_GET['ai_threshold'] );
    774             $threshold = max( 0.5, min( 1.0, $threshold ) );
     778            $threshold = max( 0.1, min( 1.0, $threshold ) );
    775779        }
    776780
     
    12211225        if ( isset( $_GET['ai_threshold'] ) ) {
    12221226            $current_threshold = floatval( $_GET['ai_threshold'] );
    1223             $current_threshold = max( 0.5, min( 1.0, $current_threshold ) );
     1227            $current_threshold = max( 0.1, min( 1.0, $current_threshold ) );
    12241228        }
    12251229
     
    12401244                <input type="range"
    12411245                       id="ai-search-frontend-threshold"
    1242                        min="50"
     1246                       min="10"
    12431247                       max="100"
    12441248                       step="1"
     
    12461250                       style="width: 100%; margin: 10px 0;">
    12471251                <div style="display: flex; justify-content: space-between; font-size: 10px; color: #666; margin-bottom: 10px;">
    1248                     <span>50% - Broad</span>
     1252                    <span>10% - Very Broad</span>
    12491253                    <span>100% - Exact</span>
    12501254                </div>
     
    12851289                var label, description, color, bg;
    12861290
    1287                 if (threshold < 0.60) {
     1291                if (threshold < 0.30) {
     1292                    label = 'Very Broad Search';
     1293                    description = 'Returns almost everything, even loosely related content.';
     1294                    color = '#8B0000';
     1295                    bg = '#fff0f0';
     1296                } else if (threshold < 0.60) {
    12881297                    label = 'Broad Search';
    12891298                    description = 'Many results including loosely related content.';
     
    13971406
    13981407        $threshold = isset( $_POST['threshold'] ) ? floatval( $_POST['threshold'] ) : 0.65;
    1399         $threshold = max( 0.5, min( 1.0, $threshold ) );
     1408        $threshold = max( 0.1, min( 1.0, $threshold ) );
    14001409
    14011410        update_option( 'ai_search_similarity_threshold', $threshold );
  • ai-search/trunk/readme.txt

    r3451586 r3453818  
    33Tags: search, AI, semantic search, WooCommerce, ecommerce, product search, smart search, OpenAI
    44Tested up to: 6.8
    5 Stable tag: 1.17.0
     5Stable tag: 1.18.0
    66Requires PHP: 8.0
    77License: GPLv2
     
    122122
    123123== Changelog ==
     124
     125= 1.18.0 =
     126- **REST API Settings Endpoint**: New public endpoint at `/wp-json/ai-search/v1/settings` exposing plugin configuration for debugging (no sensitive data)
     127- **OpenAI Model Selection**: Choose between `text-embedding-3-small` (default, recommended) and `text-embedding-3-large` when using your own OpenAI API key
     128- **Extended Threshold Range**: Similarity threshold now supports 10-100% (previously 50-100%) for broader search flexibility
     129- **Updated Default Model**: OpenAI embeddings now use `text-embedding-3-small` instead of the older `text-embedding-ada-002`
    124130
    125131= 1.17.0 =
Note: See TracChangeset for help on using the changeset viewer.