Connection successful! AI Search Service is working correctly.

'; if ( isset( $validation_data['client'] ) ) { $client = $validation_data['client']; $used_total = intval( $client['used_total'] ?? 0 ); $total_limit = intval( $client['total_limit'] ?? 10000 ); $remaining = $total_limit - $used_total; echo '

Embeddings used: ' . esc_html( number_format( $used_total ) ) . ' / ' . esc_html( number_format( $total_limit ) ) . ' (' . esc_html( number_format( $remaining ) ) . ' remaining)

'; } echo ''; delete_transient( 'ai_search_validation_data' ); } } elseif ( $validation_status === 'invalid' ) { $error_data = get_transient( 'ai_search_validation_error' ); echo '

Connection failed!

'; if ( $error_data && isset( $error_data['details'] ) ) { echo '

' . esc_html( $error_data['details'] ) . '

'; } echo '
'; delete_transient( 'ai_search_validation_error' ); } elseif ( $validation_status === 'error' ) { echo '

Connection failed! Unable to reach AI Search Service. Please try again later.

'; } elseif ( $validation_status === 'no_token' ) { echo '

Not registered. Please save your settings to register with the AI Search Service.

'; } } // Handle form submission if ( isset( $_POST['provider'], $_POST['api_key'], $_POST['similarity_threshold'] ) ) { check_admin_referer( 'ai_search_save_settings' ); $new_provider = sanitize_text_field( $_POST['provider'] ); $current_provider = get_option( 'ai_search_provider', '' ); // Save the basic settings update_option( 'ai_search_provider', $new_provider ); update_option( 'ai_search_api_key', sanitize_text_field( wp_unslash( $_POST['api_key'] ) ) ); update_option( 'ai_search_similarity_threshold', floatval( $_POST['similarity_threshold'] ) ); // Save badge public visibility option update_option( 'ai_search_badge_public', isset( $_POST['badge_public'] ) && $_POST['badge_public'] === '1' ); // Handle AI service registration $service_client = new AI_Search_Service(); if ( $new_provider === 'ai_service' && empty( get_option( 'ai_search_service_token', '' ) ) ) { $service_token = $service_client->register_origin(); if ( $service_token ) { update_option( 'ai_search_service_token', $service_token ); echo '

Settings saved successfully! AI Search Service registered.

'; } else { update_option( 'ai_search_provider', $current_provider ); echo '

AI Search Service is temporarily unavailable. Please try again later or use your own OpenAI API key instead.

'; } } else { echo '

Settings saved successfully!

'; } } ?>

Choose between using our external service (no API key needed) or managing embeddings yourself with an OpenAI key. No personal data is stored or used for other purposes.




Status: Registered with AI Search Service

Status: Not registered. Save settings to register automatically.





AI Search

Similarity Threshold

The most important setting - controls search accuracy

%
20% - More Results 30-50% Recommended 100% - Exact Match
BALANCED
Balanced Search

Good balance between precision and coverage - finds relevant results without being too strict.

How it works: This threshold defines the minimum similarity score (0-1) required for a post to appear in search results. Higher values mean stricter matching and more precise results. Lower values return more results but may include less relevant matches.



AI Search

Interactive Demo: Threshold Impact

See how threshold changes affect search results in real-time

SEARCH "I want something to use in the summer"

This query will match products based on summer-related keywords and context