Plugin Directory

Changeset 3440069


Ignore:
Timestamp:
01/15/2026 07:05:57 AM (2 months ago)
Author:
flag92
Message:

AI Provider Integration (Multi-AI Support)

Location:
click-n-chat/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • click-n-chat/trunk/README.txt

    r3433801 r3440069  
    55Tested up to: 6.9
    66Requires PHP: 5.6.4
    7 Stable tag: 1.0.9
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1010
    1111
    12 Connect with your website visitors using a free floating chat widget that supports WhatsApp, Telegram, Messenger, Instagram, Email, SMS, and more.
     12All-in-one floating chat widget with social platforms, smart auto replies, AI chatbot integration, analytics tracking, and full customization.
    1313
    1414== Description ==
     
    5656---
    5757
    58 ### 2. Social User Profile Management
     58### 2. AI-Powered Chatbot (Multi-Provider) 
     59- **Enhance conversations using modern AI providers**
     60- Supported AI Providers
     61- OpenAI (ChatGPT)
     62- Claude (Anthropic)
     63- Google Gemini
     64- HuggingFace Inference API
     65- Cohere
     66- DeepSeek
     67- **Key Highlights**
     68- Switch AI providers anytime from settings
     69- Only required API fields appear dynamically
     70- Unified AI engine (single backend class)
     71- HTML-formatted AI responses for clean chat display
     72- Compatible with PHP 7.4+
     73
     74---
     75
     76### 3. Social User Profile Management
    5977- Create multiple chat profiles
    6078- Set agent name, role, and description
     
    6684---
    6785
    68 ### 3. Floating Chat Widget
     86### 4. Floating Chat Widget
    6987- Clean bottom-right popup chat button
    7088- Displays all active chat platforms
     
    7492---
    7593
    76 ### 4. Auto-Reply Chatbot
     94### 5. Auto-Reply Chatbot
    7795- Keyword and query-based auto replies
    7896- Percentage-based matching for accuracy
     
    82100---
    83101
    84 ### 5. Design & Customization
     102### 6. Design & Customization
    85103- Popup header text and colors
    86104- Padding, borders, and icons
     
    90108---
    91109
    92 ### 6. Google Analytics Integration
     110### 7. Google Analytics Integration
    93111- Track chat widget clicks
    94112- Supports GA4 and Universal Analytics
     
    97115---
    98116
    99 ### 7. Responsive & Developer-Friendly
     117### 8. Responsive & Developer-Friendly
    100118- Works on desktop, tablet, and mobile
    101119- Cross-browser compatible
     
    137155== Changelog ==
    138156
    139 = 1.0.9 12 December 2024 =
     157= 1.1.0 15 January 2026 =
     158* Updated chat icon
     159* AI Provider Integration (Multi-AI Support)
     160
     161= 1.0.9 12 December 2025 =
    140162* Updated chat icon
    141163* Tested with latest WordPress version
  • click-n-chat/trunk/admin/assets/js/admin-script.js

    r3267900 r3440069  
    387387        $('#' + tabId).show();
    388388    });
     389   
     390    function toggleApiFields() {
     391        const provider = document.getElementById('ai_provider').value;
     392
     393        document.querySelectorAll('.cnc-ai-key').forEach(function (el) {
     394            el.style.display = 'none';
     395        });
     396
     397        const active = document.querySelector(
     398            '.cnc-ai-key[data-provider="' + provider + '"]'
     399        );
     400
     401        if (active) {
     402            active.style.display = 'block';
     403        }
     404    }
     405
     406    document.getElementById('ai_provider').addEventListener(
     407        'change',
     408        toggleApiFields
     409    );
     410
     411    // Run on page load
     412    toggleApiFields();
    389413});
    390414
  • click-n-chat/trunk/admin/includes/click_n_chat_menu.php

    r3267900 r3440069  
    8585                <a href="?page=wa-clicknchat&tab=woocommerce" class="cnc-nav-tab <?php echo esc_html($active_tab == 'woocommerce' ? 'nav-tab-is-active' : ''); ?>">WooCommerce</a>
    8686               
    87                 <a href="?page=wa-clicknchat&tab=chatgpt" class="cnc-nav-tab <?php echo esc_html($active_tab == 'chatgpt' ? 'nav-tab-is-active' : ''); ?>">ChatGPT</a>
     87                <a href="?page=wa-clicknchat&tab=chatgpt" class="cnc-nav-tab <?php echo esc_html($active_tab == 'chatgpt' ? 'nav-tab-is-active' : ''); ?>">AI Integration</a>
    8888               
    8989                <a href="?page=wa-clicknchat&tab=autoreply" class="cnc-nav-tab <?php echo esc_html($active_tab == 'autoreply' ? 'nav-tab-is-active' : ''); ?>">Auto Reply</a>
  • click-n-chat/trunk/admin/includes/pages/click_n_chat_chatgpt.php

    r3267900 r3440069  
    1414        }
    1515        $click_n_chat_setting_chatgpt = new click_n_chat_setting_chatgpt();
    16         $click_n_chat_setting_chatgpt->api_key = sanitize_text_field($_POST['api_key']);
     16
     17        $click_n_chat_setting_chatgpt->ai_provider = sanitize_text_field($_POST['ai_provider']);
     18       
     19        $click_n_chat_setting_chatgpt->openai_api_key = sanitize_text_field($_POST['openai_api_key']);
     20        $click_n_chat_setting_chatgpt->claude_api_key = sanitize_text_field($_POST['claude_api_key']);
     21        $click_n_chat_setting_chatgpt->huggingface_api_key = sanitize_text_field($_POST['huggingface_api_key']);
     22        $click_n_chat_setting_chatgpt->gemini_api_key = sanitize_text_field($_POST['gemini_api_key']);
     23        $click_n_chat_setting_chatgpt->cohere_api_key = sanitize_text_field($_POST['cohere_api_key']);
     24        $click_n_chat_setting_chatgpt->deepseek_api_key = sanitize_text_field($_POST['deepseek_api_key']);
     25       
    1726        $click_n_chat_setting_chatgpt->max_token = sanitize_text_field($_POST['max_token']);
    1827        $click_n_chat_setting_chatgpt->temperature = sanitize_text_field($_POST['temperature']);
     
    2029        $click_n_chat_setting_chatgpt->frequency_penalty = sanitize_text_field($_POST['frequency_penalty']);
    2130        $click_n_chat_setting_chatgpt->ai_models = sanitize_text_field($_POST['ai_models']);
    22         $click_n_chat_setting_chatgpt->include_auto_reply = $_POST['include_auto_reply'] == "on" ? 1 : 0;
    23         $click_n_chat_setting_chatgpt->ai_instructions =  ($_POST['ai_instructions']);
     31        $click_n_chat_setting_chatgpt->include_auto_reply = isset($_POST['include_auto_reply']) ? 1 : 0;
     32        $click_n_chat_setting_chatgpt->ai_instructions = wp_kses_post($_POST['ai_instructions']);
    2433       
    2534        update_option('click_n_chat_setting_chatgpt', $click_n_chat_setting_chatgpt);
     
    4150                <div class="tab-pane fade show active" id="chatgpt" role="tabpanel" aria-labelledby="chatgpt-tab">
    4251                    <div class="form-field">
    43                         <label for="is_active">API Key: </label>
    44                         <input name="api_key" type="password" id="api_key" value="<?php echo esc_html($click_n_chat_setting_chatgpt->api_key);  ?>" class="regular-text">
    45                     </div>
     52                        <label>AI Provider:</label>
     53                       <select name="ai_provider" id="ai_provider" class="form-select cnc-select">
     54                            <option value="openai" <?php selected($click_n_chat_setting_chatgpt->ai_provider, 'openai'); ?>>OpenAI</option>
     55                            <option value="claude" <?php selected($click_n_chat_setting_chatgpt->ai_provider, 'claude'); ?>>Claude (Anthropic)</option>
     56                            <option value="huggingface" <?php selected($click_n_chat_setting_chatgpt->ai_provider, 'huggingface'); ?>>HuggingFace</option>
     57                            <option value="gemini" <?php selected($click_n_chat_setting_chatgpt->ai_provider, 'gemini'); ?>>Google Gemini</option>
     58                            <option value="cohere" <?php selected($click_n_chat_setting_chatgpt->ai_provider, 'cohere'); ?>>Cohere</option>
     59                            <option value="deepseek" <?php selected($click_n_chat_setting_chatgpt->ai_provider, 'deepseek'); ?>>DeepSeek</option>
     60                        </select>
     61                    </div>
     62                    <div class="form-field cnc-ai-key" data-provider="openai">
     63                        <label>OpenAI API Key</label>
     64                        <input type="password" name="openai_api_key"
     65                            value="<?php echo esc_attr($click_n_chat_setting_chatgpt->openai_api_key); ?>"
     66                            class="regular-text">
     67                    </div>
     68
     69                   
     70                    <div class="form-field cnc-ai-key" data-provider="claude">
     71                        <label>Claude API Key</label>
     72                        <input type="password" name="claude_api_key"
     73                            value="<?php echo esc_attr($click_n_chat_setting_chatgpt->claude_api_key); ?>"
     74                            class="regular-text">
     75                    </div>
     76
     77                   
     78                    <div class="form-field cnc-ai-key" data-provider="huggingface">
     79                        <label>HuggingFace API Key</label>
     80                        <input type="password" name="huggingface_api_key"
     81                            value="<?php echo esc_attr($click_n_chat_setting_chatgpt->huggingface_api_key); ?>"
     82                            class="regular-text">
     83                    </div>
     84
     85                   
     86                    <div class="form-field cnc-ai-key" data-provider="gemini">
     87                        <label>Gemini API Key</label>
     88                        <input type="password" name="gemini_api_key"
     89                            value="<?php echo esc_attr($click_n_chat_setting_chatgpt->gemini_api_key); ?>"
     90                            class="regular-text">
     91                    </div>
     92
     93                   
     94                    <div class="form-field cnc-ai-key" data-provider="cohere">
     95                        <label>Cohere API Key</label>
     96                        <input type="password" name="cohere_api_key"
     97                            value="<?php echo esc_attr($click_n_chat_setting_chatgpt->cohere_api_key); ?>"
     98                            class="regular-text">
     99                    </div>
     100
     101                   
     102                    <div class="form-field cnc-ai-key" data-provider="deepseek">
     103                        <label>DeepSeek API Key</label>
     104                        <input type="password" name="deepseek_api_key"
     105                            value="<?php echo esc_attr($click_n_chat_setting_chatgpt->deepseek_api_key); ?>"
     106                            class="regular-text">
     107                    </div>
     108                    <div class="form-field">
     109                        <select name="ai_models" class="form-select cnc-select">
     110   
     111                            <optgroup label="OpenAI">
     112                                <option value="gpt-3.5-turbo">GPT-3.5 Turbo</option>
     113                                <option value="gpt-4">GPT-4</option>
     114                                <option value="gpt-4o">GPT-4o</option>
     115                            </optgroup>
     116                       
     117                            <optgroup label="Claude">
     118                                <option value="claude-3-opus">Claude 3 Opus</option>
     119                                <option value="claude-3-sonnet">Claude 3 Sonnet</option>
     120                            </optgroup>
     121                       
     122                            <optgroup label="HuggingFace">
     123                                <option value="meta-llama/Llama-3-8b-chat-hf">LLaMA-3</option>
     124                                <option value="mistralai/Mistral-7B-Instruct">Mistral</option>
     125                            </optgroup>
     126                       
     127                            <optgroup label="Gemini">
     128                                <option value="gemini-1.5-flash">Gemini Flash</option>
     129                                <option value="gemini-1.5-pro">Gemini Pro</option>
     130                            </optgroup>
     131                       
     132                            <optgroup label="Cohere">
     133                                <option value="command-r">Command-R</option>
     134                                <option value="command-r-plus">Command-R+</option>
     135                            </optgroup>
     136                       
     137                            <optgroup label="DeepSeek">
     138                                <option value="deepseek-chat">DeepSeek Chat</option>
     139                            </optgroup>
     140                       
     141                        </select>
     142                    </div>
     143                   
    46144                    <div class="form-field">
    47145                        <label for="is_active">Max Tokens (0 - 4000): </label>
     
    75173                        </p>
    76174                    </div>
    77                     <div class="form-field">
    78                         <label for="is_active">ChatGPT AI Models: </label>
    79                         <select name="ai_models" class="form-select cnc-select">               
    80                             <option <?php echo esc_html($click_n_chat_setting_chatgpt->ai_models == "gpt-3.5-turbo" ? 'selected' : '');  ?> value="gpt-3.5-turbo">GPT-3 turbo</option>
    81                             <option <?php echo esc_html($click_n_chat_setting_chatgpt->ai_models == "gpt-4" ? 'selected' : '');  ?> value="gpt-4">GPT-4</option>
    82                         </select>
    83                     </div>
     175                   
    84176                    <div class="form-field">
    85177                        <label for="is_active">Include Auto Reply: </label>
     
    95187            </div>
    96188            <p class="submit">
    97                 <input type="submit" name="submit" id="submit" class="button button-primary" value="Update ChatGPT Setting">
     189                <input type="submit" name="submit" id="submit" class="button button-primary" value="Update AI Setting">
    98190            </p>
    99191        </div>
  • click-n-chat/trunk/admin/includes/pages/click_n_chat_setting.php

    r3267900 r3440069  
    261261&lt;br /&gt;
    262262&lt;p style=&quot;color:#3d3d3d; font-size:11px; color:#FFFFFF&quot;&gt;
    263     &lt;b&gt;Click n Chat&lt;/b&gt; Social Solution with AI-driven ChatGPT Chatbot.
     263    &lt;b&gt;Click n Chat&lt;/b&gt; Social Solution with AI-driven AI Chatbot.
    264264&lt;/p&gt;
    265265</div>
     
    535535                                <span class="pop_type_hover">
    536536                                    <input type="radio" name="pop_type" value="chatgpt" <?php echo esc_html($click_n_chat_setting_popup->pop_type == "chatgpt" ? 'checked="checked"' : '');  ?> data-img="chatgpt">
    537                                     ChatGPT
     537                                    AI 
    538538                                </span>
    539539                               
     
    549549                            <input name="socialwidgets_no_availability" <?php echo esc_html($click_n_chat_setting_popup->socialwidgets_no_availability == "autoreply" ? 'checked="checked"' : '');  ?> type="radio" value="autoreply" /> Auto Reply
    550550                           
    551                             <input name="socialwidgets_no_availability" <?php echo esc_html($click_n_chat_setting_popup->socialwidgets_no_availability == "chatgpt" ? 'checked="checked"' : '');  ?> type="radio" value="chatgpt" /> ChatGPT
     551                            <input name="socialwidgets_no_availability" <?php echo esc_html($click_n_chat_setting_popup->socialwidgets_no_availability == "chatgpt" ? 'checked="checked"' : '');  ?> type="radio" value="chatgpt" /> AI
    552552                           
    553553                        </div>   
     
    567567                                <option <?php echo esc_html($click_n_chat_setting_popup->display_front_page == "0" ? 'selected' : '');  ?> value="0">None</option>
    568568                                <option <?php echo esc_html($click_n_chat_setting_popup->display_front_page == "1" ? 'selected' : '');  ?> value="1">Auto Reply</option>
    569                                 <option <?php echo esc_html($click_n_chat_setting_popup->display_front_page == "2" ? 'selected' : '');  ?> value="2">ChatGPT</option>
     569                                <option <?php echo esc_html($click_n_chat_setting_popup->display_front_page == "2" ? 'selected' : '');  ?> value="2">AI</option>
    570570                                <option <?php echo esc_html($click_n_chat_setting_popup->display_front_page == "3" ? 'selected' : '');  ?> value="3">Social Icon</option>
    571571                                <option <?php echo esc_html($click_n_chat_setting_popup->display_front_page == "4" ? 'selected' : '');  ?> value="4">Social Widgets</option>
     
    578578                                <option <?php echo esc_html($click_n_chat_setting_popup->display_home == "0" ? 'selected' : '');  ?> value="0">None</option>
    579579                                <option <?php echo esc_html($click_n_chat_setting_popup->display_home == "1" ? 'selected' : '');  ?> value="1">Auto Reply</option>
    580                                 <option <?php echo esc_html($click_n_chat_setting_popup->display_home == "2" ? 'selected' : '');  ?> value="2">ChatGPT</option>
     580                                <option <?php echo esc_html($click_n_chat_setting_popup->display_home == "2" ? 'selected' : '');  ?> value="2">AI</option>
    581581                                <option <?php echo esc_html($click_n_chat_setting_popup->display_home == "3" ? 'selected' : '');  ?> value="3">Social Icon</option>
    582582                                <option <?php echo esc_html($click_n_chat_setting_popup->display_home == "4" ? 'selected' : '');  ?> value="4">Social Widgets</option>
     
    588588                                <option <?php echo esc_html($click_n_chat_setting_popup->display_cart == "0" ? 'selected' : '');  ?> value="0">None</option>
    589589                                <option <?php echo esc_html($click_n_chat_setting_popup->display_cart == "1" ? 'selected' : '');  ?> value="1">Auto Reply</option>
    590                                 <option <?php echo esc_html($click_n_chat_setting_popup->display_cart == "2" ? 'selected' : '');  ?> value="2">ChatGPT</option>
     590                                <option <?php echo esc_html($click_n_chat_setting_popup->display_cart == "2" ? 'selected' : '');  ?> value="2">AI</option>
    591591                                <option <?php echo esc_html($click_n_chat_setting_popup->display_cart == "3" ? 'selected' : '');  ?> value="3">Social Icon</option>
    592592                                <option <?php echo esc_html($click_n_chat_setting_popup->display_cart == "4" ? 'selected' : '');  ?> value="4">Social Widgets</option>
     
    598598                                <option <?php echo esc_html($click_n_chat_setting_popup->display_checkout == "0" ? 'selected' : '');  ?> value="0">None</option>
    599599                                <option <?php echo esc_html($click_n_chat_setting_popup->display_checkout == "1" ? 'selected' : '');  ?> value="1">Auto Reply</option>
    600                                 <option <?php echo esc_html($click_n_chat_setting_popup->display_checkout == "2" ? 'selected' : '');  ?> value="2">ChatGPT</option>
     600                                <option <?php echo esc_html($click_n_chat_setting_popup->display_checkout == "2" ? 'selected' : '');  ?> value="2">AI</option>
    601601                                <option <?php echo esc_html($click_n_chat_setting_popup->display_checkout == "3" ? 'selected' : '');  ?> value="3">Social Icon</option>
    602602                                <option <?php echo esc_html($click_n_chat_setting_popup->display_checkout == "4" ? 'selected' : '');  ?> value="4">Social Widgets</option>
     
    608608                                <option <?php echo esc_html($click_n_chat_setting_popup->display_page == "0" ? 'selected' : '');  ?> value="0">None</option>
    609609                                <option <?php echo esc_html($click_n_chat_setting_popup->display_page == "1" ? 'selected' : '');  ?> value="1">Auto Reply</option>
    610                                 <option <?php echo esc_html($click_n_chat_setting_popup->display_page == "2" ? 'selected' : '');  ?> value="2">ChatGPT</option>
     610                                <option <?php echo esc_html($click_n_chat_setting_popup->display_page == "2" ? 'selected' : '');  ?> value="2">AI</option>
    611611                                <option <?php echo esc_html($click_n_chat_setting_popup->display_page == "3" ? 'selected' : '');  ?> value="3">Social Icon</option>
    612612                                <option <?php echo esc_html($click_n_chat_setting_popup->display_page == "4" ? 'selected' : '');  ?> value="4">Social Widgets</option>
     
    618618                                <option <?php echo esc_html($click_n_chat_setting_popup->display_account_page == "0" ? 'selected' : '');  ?> value="0">None</option>
    619619                                <option <?php echo esc_html($click_n_chat_setting_popup->display_account_page == "1" ? 'selected' : '');  ?> value="1">Auto Reply</option>
    620                                 <option <?php echo esc_html($click_n_chat_setting_popup->display_account_page == "2" ? 'selected' : '');  ?> value="2">ChatGPT</option>
     620                                <option <?php echo esc_html($click_n_chat_setting_popup->display_account_page == "2" ? 'selected' : '');  ?> value="2">AI</option>
    621621                                <option <?php echo esc_html($click_n_chat_setting_popup->display_account_page == "3" ? 'selected' : '');  ?> value="3">Social Icon</option>
    622622                                <option <?php echo esc_html($click_n_chat_setting_popup->display_account_page == "4" ? 'selected' : '');  ?> value="4">Social Widgets</option>
     
    628628                                <option <?php echo esc_html($click_n_chat_setting_popup->display_shop == "0" ? 'selected' : '');  ?> value="0">None</option>
    629629                                <option <?php echo esc_html($click_n_chat_setting_popup->display_shop == "1" ? 'selected' : '');  ?> value="1">Auto Reply</option>
    630                                 <option <?php echo esc_html($click_n_chat_setting_popup->display_shop == "2" ? 'selected' : '');  ?> value="2">ChatGPT</option>
     630                                <option <?php echo esc_html($click_n_chat_setting_popup->display_shop == "2" ? 'selected' : '');  ?> value="2">AI</option>
    631631                                <option <?php echo esc_html($click_n_chat_setting_popup->display_shop == "3" ? 'selected' : '');  ?> value="3">Social Icon</option>
    632632                                <option <?php echo esc_html($click_n_chat_setting_popup->display_shop == "4" ? 'selected' : '');  ?> value="4">Social Widgets</option>
     
    638638                                <option <?php echo esc_html($click_n_chat_setting_popup->display_product == "0" ? 'selected' : '');  ?> value="0">None</option>
    639639                                <option <?php echo esc_html($click_n_chat_setting_popup->display_product == "1" ? 'selected' : '');  ?> value="1">Auto Reply</option>
    640                                 <option <?php echo esc_html($click_n_chat_setting_popup->display_product == "2" ? 'selected' : '');  ?> value="2">ChatGPT</option>
     640                                <option <?php echo esc_html($click_n_chat_setting_popup->display_product == "2" ? 'selected' : '');  ?> value="2">AI</option>
    641641                                <option <?php echo esc_html($click_n_chat_setting_popup->display_product == "3" ? 'selected' : '');  ?> value="3">Social Icon</option>
    642642                                <option <?php echo esc_html($click_n_chat_setting_popup->display_product == "4" ? 'selected' : '');  ?> value="4">Social Widgets</option>
     
    660660                    </p>
    661661                    <p>
    662                         <b>ChatGPT: </b> Onclick chat popup opens chat using <a href="?page=wa-clicknchat&tab=chatgpt">ChatGPT</a>
     662                        <b>AI: </b> Onclick chat popup opens chat using <a href="?page=wa-clicknchat&tab=chatgpt">AI</a>
    663663                    </p>
    664664                    <p>
  • click-n-chat/trunk/classes/click_n_chat_setting_chatgpt.php

    r3267891 r3440069  
    11<?php
    2 if (!defined('ABSPATH')) {
    3     exit; // Exit if accessed directly
    4 }
     2if (!defined('ABSPATH')) exit;
    53
    64if (!class_exists('click_n_chat_setting_chatgpt')) {
    75    class click_n_chat_setting_chatgpt {
    8         public $api_key = 'Flag92';
     6
     7        /* Provider */
     8        public $ai_provider = 'openai';
     9
     10        /* API Keys */
     11        public $openai_api_key = '';
     12        public $claude_api_key = '';
     13        public $huggingface_api_key = '';
     14        public $gemini_api_key = '';
     15        public $cohere_api_key = '';
     16        public $deepseek_api_key = '';
     17
     18        /* Common */
    919        public $max_token = '500';
    1020        public $temperature = '0.5';
     
    1323        public $ai_models = 'gpt-3.5-turbo';
    1424        public $include_auto_reply = '1';
    15         public $ai_instructions = 'You are a virtual assistant for a clothing store, specifically designed to help customers with the checkout process. Assist customers by guiding them through each step of the checkout process, including reviewing their cart, applying discount codes, selecting shipping options, and completing payment. Provide clear and accurate information, and ensure a smooth and user-friendly checkout experience. Address any questions or issues they may have related to the checkout process.';
     25        public $ai_instructions = 'You are a helpful AI assistant.';
    1626    }
    1727}
  • click-n-chat/trunk/click-n-chat.php

    r3433801 r3440069  
    44Plugin URI: http://www.flag92.com/
    55Description: Chat n Click allows you to connect with website visitors through their favorite social channels by displaying a floating chat icon at the bottom of your site. With features like AI chat, auto-reply, widget customization, you can ensure seamless communication and enhance visitor engagement across multiple platforms.
    6 Version: 1.0.9
     6Version: 1.1.0
    77Author: Flag92
    88Domain Path: /languages
  • click-n-chat/trunk/includes/ajax/click_n_chat_ajax_get_ai_reply.php

    r3267900 r3440069  
    3636    if($reply_message == "")
    3737    {
    38         $url = 'https://api.openai.com/v1/chat/completions';
    39         $htmlInstructions = 'Respond to the user inquiry in HTML format. Format the text with appropriate HTML tags, including <strong> for bold text, <ul> and <li> for lists, and <p> for paragraphs.';
    40        
    41         $data = [
    42             'model' => $click_n_chat_setting_chatgpt->ai_models,
    43             'messages' => [
    44                 ['role' => 'system', 'content' => $click_n_chat_setting_chatgpt->ai_instructions.' '.$htmlInstructions],
    45                 ['role' => 'user', 'content' => $message]
    46             ],
    47             'max_tokens' =>  (float)$click_n_chat_setting_chatgpt->max_token,
    48             'temperature' =>  (float)$click_n_chat_setting_chatgpt->temperature,
    49             'presence_penalty' =>  (float)$click_n_chat_setting_chatgpt->presence_penalty,
    50             'frequency_penalty' =>  (float)$click_n_chat_setting_chatgpt->frequency_penalty
    51         ];
    52        
    53         $args = [
    54             'headers' => [
    55                 'Authorization' => 'Bearer ' . $click_n_chat_setting_chatgpt->api_key,
    56                 'Content-Type'  => 'application/json',
    57             ],
    58             'body' => wp_json_encode($data),  // Ensure the data is in JSON format
    59             'method' => 'POST',
    60             'timeout' => 30, // Timeout in seconds
    61         ];
    62         $response = wp_remote_post($url, $args);
    63        
    64         if (is_wp_error($response)) {
    65             $reply_message = 'Error: ' . $response->get_error_message();
    66         }
    67         else
    68         {
    69            
    70             $response_body = wp_remote_retrieve_body($response);
    71             $responseData = json_decode($response_body);
    72 
    73             if(isset($responseData->choices[0]->message->content))
    74                 $reply_message = $responseData->choices[0]->message->content;
    75             else
    76                 $reply_message = $responseData->error->message;
    77            
    78         }
     38        $ai = new Click_N_Chat_AI_Provider($settings);
     39        $reply_message = $ai->reply($message);
    7940    }
    8041 
     
    11778
    11879    return $results[0];
    119 }   
     80}      
    12081 
    12182add_action('wp_ajax_click_n_chat_get_ai_action', 'click_n_chat_get_ai_action_handler'); 
Note: See TracChangeset for help on using the changeset viewer.