Plugin Directory

Changeset 3468129


Ignore:
Timestamp:
02/24/2026 01:18:46 AM (5 weeks ago)
Author:
oc3dots
Message:

Fix missing method error

Location:
s2b-ai-assistant/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • s2b-ai-assistant/trunk/lib/agents/addons/seo-readability-rewrite-agent/SeoReadabilityRewriteAgent.php

    r3466659 r3468129  
    473473
    474474        // Optional: extract any custom prompt the user provided in the first message
    475         $custom_prompt = '';
    476         $messages = S2baia_MessageHelper::get_message_history((int) $this->task->id);
    477         if (!empty($messages)) {
    478             foreach ($messages as $msg) {
    479                 if (($msg['role'] ?? '') === 'user' && isset($msg['content']['custom_prompt'])) {
    480                     $custom_prompt = wp_strip_all_tags((string) $msg['content']['custom_prompt']);
    481                     break;
     475
     476        $stored_prompt = [];
     477        if (method_exists('S2baia_MessageHelper', 'get_latest_user_payload')) {
     478            $stored_prompt = S2baia_MessageHelper::get_latest_user_payload((int) $this->task->id);
     479            if (!is_array($stored_prompt)) { $stored_prompt = []; }
     480        } else {
     481            // Fallback: scan history, decode JSON content
     482            $messages = S2baia_MessageHelper::get_message_history($this->task->id);
     483            if (!empty($messages)) {
     484                foreach ($messages as $msg) {
     485                    if (($msg['role'] ?? '') !== 'user') { continue; }
     486                    $raw = $msg['content'] ?? '';
     487                    if (is_string($raw) && $raw !== '') {
     488                        $decoded = json_decode($raw, true);
     489                        if (is_array($decoded)) {
     490                            $stored_prompt = $decoded;
     491                            break;
     492                        }
     493                    }
    482494                }
    483495            }
    484496        }
    485497
     498        $custom_prompt    = isset($stored_prompt['custom_prompt']) ? (string) $stored_prompt['custom_prompt'] : '';
    486499        // Decide instructions by strategy
    487500        $lang_hint = $language !== '' ? $language : 'unknown';
     
    580593        $call_obj->timeout = $timeout;
    581594        $call_obj->prompt = $prompt;
    582 
     595       
    583596        // Optional: allow filtering the call object before dispatch
    584597        $call_obj = apply_filters(
     
    11661179        // Save the user message (optional custom instructions) into message history
    11671180        if ($custom_prompt !== '') {
    1168             S2baia_MessageHelper::add_message($task_id, 'user', ['custom_prompt' => $custom_prompt]);
     1181            S2baia_MessageHelper::upsert_user_payload((int)$task_id, array(
     1182                'custom_prompt'        => $custom_prompt,
     1183            ));
    11691184        }
    11701185
  • s2b-ai-assistant/trunk/lib/agents/tools/OpenAITools.php

    r3466659 r3468129  
    165165            return ['response' => 'OpenAI API error: ' . $data['error']['message']];
    166166        }
    167 
     167       
    168168        return ['response' => $data['choices'][0]['message']['content'] ?? 'No response.'];
    169169    }
  • s2b-ai-assistant/trunk/readme.txt

    r3466657 r3468129  
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    10 Stable tag: 1.9.0
     10Stable tag: 1.9.1
    1111
    1212Create multiple AI chatbots with OpenAI, Claude, xAI, DeepSeek models with different styles, AI Agents with Chatkit ...
     
    257257== Changelog ==
    258258
     259= 1.9.1 =
     260*  Fix missing method error
     261
    259262= 1.9.0 =
    260263*  Added  file upload support for Chatkit.
  • s2b-ai-assistant/trunk/s2b-ai-assistant.php

    r3466657 r3468129  
    88  Text Domain: s2b-ai-assistant
    99  Domain Path: /lang
    10   Version: 1.9.0
     10  Version: 1.9.1
    1111  License:  GPL-2.0+
    1212  License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
     
    4343define( 'S2BAIA_CHATGPT_BOT_PREFIX', 's2baia_chatbot_' );
    4444define( 'S2BAIA_CHATGPT_BOT_OPTIONS_PREFIX', 's2baia_chatbot_opt_' );
    45 define('S2BAIA_VERSION', '1.9.0');
     45define('S2BAIA_VERSION', '1.9.1');
    4646//Init the plugin
    4747require_once S2BAIA_PATH . '/lib/helpers/Utils.php';
Note: See TracChangeset for help on using the changeset viewer.