PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 8.0.5
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v8.0.5
8.0.5 8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 All 47 releases
gamipress / modules / ai-assistant / includes / abilities.php

abilities.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 8.0.5, at modules/ai-assistant/includes/abilities.php

96 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Abilities
4 *
5 * @package GamiPress\AI_Assistant\Abilities
6 * @since 1.0.0
7 * @version 1.0.0
8 */
9 // Exit if accessed directly
10 if ( ! defined( 'ABSPATH' ) ) exit;
11
12 /**
13 * Get the system instructions
14 *
15 * @since 1.0.0
16 */
17 function gamipress_ai_assistant_get_system_instructions() {
18
19 $points_types = gamipress_get_points_types_slugs();
20 $achievement_types = gamipress_get_achievement_types_slugs();
21 $rank_types = gamipress_get_rank_types_slugs();
22
23 $system_instructions = array(
24 "You are an AI assistant for GamiPress.",
25 "Be helpful, precise, and professional.",
26 "You have strict catalog restrictions due to ability parameters.",
27 "Do not guess slugs for points, achievements or ranks.",
28 "The types available in this site are:",
29 "Points types: " . implode( ', ', $points_types ) . ".",
30 "Achievement types: " . implode( ', ', $achievement_types ) . ".",
31 "Rank types: " . implode( ', ', $rank_types ) . ".",
32 "Do not guess slugs for triggers, activities or events when configuring requirements.",
33 "Always use the listed abilities to perform tasks instead of guessing or pretending.",
34 "Do not generate a text response after using abilities. They already return one.",
35 );
36
37 /**
38 * Filter to override the system instructions
39 *
40 * @since 1.0.0
41 *
42 * @param string $system_instructions
43 *
44 * @return string
45 */
46 return apply_filters( 'gamipress_ai_assistant_get_system_instructions', implode( ' ', $system_instructions ) );
47 }
48
49 /**
50 * Register abilities category
51 *
52 * @since 1.0.0
53 */
54 function gamipress_ai_assistant_register_category() {
55 if ( ! function_exists( 'wp_register_ability_category' ) ) return;
56
57 wp_register_ability_category( 'gamipress', array(
58 'label' => __( 'GamiPress', 'gamipress' ),
59 'description' => __( 'Ability to manage, create and design GamiPress elements such as points, achievements and ranks using AI.', 'gamipress' ),
60 ) );
61
62 }
63 add_action( 'wp_abilities_api_categories_init', 'gamipress_ai_assistant_register_category' );
64
65 /**
66 * Get abilities
67 *
68 * @since 1.0.0
69 *
70 * @return array
71 */
72 function gamipress_ai_assistant_get_abilities() {
73
74 $registered = wp_get_abilities();
75 $categories = array();
76
77 foreach( $registered as $ability => $object ) {
78 if( strpos( $ability, 'gamipress' ) !== false ) {
79 $categories[$ability] = $object;
80 }
81 }
82
83 return $categories;
84 }
85
86 /**
87 * Get abilities slugs
88 *
89 * @since 1.0.0
90 *
91 * @return array
92 */
93 function gamipress_ai_assistant_get_abilities_slugs() {
94 return array_keys( gamipress_ai_assistant_get_abilities() );
95 }
96