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-registry.php

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

83 lines 1.7 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_Registry' ) ) :
7
8 final class WPSC_ACB_Tool_Registry {
9
10 /**
11 * Get registered chatbot function-calling tools.
12 *
13 * @return array
14 */
15 public static function get_registry() {
16
17 $registry = array();
18 return apply_filters( 'wpsc_acb_tool_registry', $registry );
19 }
20
21 /**
22 * Get provider-ready tool definitions.
23 *
24 * @return array
25 */
26 public static function get_tool_definitions() {
27
28 $registry = self::get_registry();
29 $tools = array();
30
31 foreach ( $registry as $tool ) {
32 if ( empty( $tool['name'] ) || empty( $tool['description'] ) || empty( $tool['parameters'] ) ) {
33 continue;
34 }
35
36 $tools[] = array(
37 'name' => $tool['name'],
38 'description' => $tool['description'],
39 'parameters' => $tool['parameters'],
40 );
41 }
42
43 return $tools;
44 }
45
46 /**
47 * Get handler method name for a tool.
48 *
49 * @param string $tool_name Tool name.
50 * @return string
51 */
52 public static function get_tool_handler( $tool_name ) {
53
54 $tool_name = sanitize_key( (string) $tool_name );
55 $registry = self::get_registry();
56
57 if ( empty( $registry[ $tool_name ]['handler'] ) ) {
58 return '';
59 }
60
61 return (string) $registry[ $tool_name ]['handler'];
62 }
63
64 /**
65 * Get handler class name for a tool.
66 *
67 * @param string $tool_name Tool name.
68 * @return string
69 */
70 public static function get_tool_handler_class( $tool_name ) {
71
72 $tool_name = sanitize_key( (string) $tool_name );
73 $registry = self::get_registry();
74
75 if ( empty( $registry[ $tool_name ]['class'] ) ) {
76 return '';
77 }
78
79 return (string) $registry[ $tool_name ]['class'];
80 }
81 }
82 endif;
83