PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.5.1
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.5.1
3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / includes / admin / ai-chatbot / tools / class-wpsc-acb-tool-executor.php

class-wpsc-acb-tool-executor.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 3.5.1, at includes/admin/ai-chatbot/tools/class-wpsc-acb-tool-executor.php

35 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly!
4 }
5
6 if ( ! class_exists( 'WPSC_ACB_Tool_Executor' ) ) :
7
8 final class WPSC_ACB_Tool_Executor {
9
10 /**
11 * Execute a tool call.
12 *
13 * @param array $tool_call Tool call payload.
14 * @param string $session_uuid Session ID or internal session ID.
15 * @return array
16 */
17 public static function execute_tool_call( $tool_call, $session_uuid ) {
18
19 $tool_name = sanitize_key( (string) ( $tool_call['name'] ?? '' ) );
20 $args = is_array( $tool_call['arguments'] ?? null ) ? $tool_call['arguments'] : array();
21 $handler = WPSC_ACB_Tool_Registry::get_tool_handler( $tool_name );
22 $class = WPSC_ACB_Tool_Registry::get_tool_handler_class( $tool_name );
23
24 if ( '' === $handler || ! is_callable( array( $class, $handler ) ) ) {
25 return array(
26 'success' => true,
27 'response' => '<p>' . esc_html__( 'I can continue helping in chat. Please tell me what you need.', 'wpsc-ps' ) . '</p>',
28 );
29 }
30
31 return call_user_func( array( $class, $handler ), $args, $session_uuid );
32 }
33 }
34 endif;
35