ai-engine
Last commit date
app
1 month ago
archives
5 months ago
classes
1 month ago
common
1 month ago
constants
1 month ago
images
11 months ago
labs
1 month ago
languages
3 months ago
themes
2 months ago
vendor
10 months ago
ai-engine.php
1 month ago
blueprint.json
2 years ago
readme.txt
1 month ago
uninstall.php
9 months ago
ai-engine.php
63 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | Plugin Name: AI Engine |
| 5 | Plugin URI: https://wordpress.org/plugins/ai-engine/ |
| 6 | Description: AI meets WordPress. Your site can now chat, write poetry, solve problems, and maybe make you coffee. |
| 7 | Version: 3.5.3 |
| 8 | Author: Jordy Meow |
| 9 | Author URI: https://jordymeow.com |
| 10 | Text Domain: ai-engine |
| 11 | License: GPLv2 or later |
| 12 | License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 13 | */ |
| 14 | |
| 15 | define( 'MWAI_VERSION', '3.5.3' ); |
| 16 | define( 'MWAI_PREFIX', 'mwai' ); |
| 17 | define( 'MWAI_DOMAIN', 'ai-engine' ); |
| 18 | define( 'MWAI_ENTRY', __FILE__ ); |
| 19 | define( 'MWAI_PATH', dirname( __FILE__ ) ); |
| 20 | define( 'MWAI_URL', plugin_dir_url( __FILE__ ) ); |
| 21 | define( 'MWAI_ITEM_ID', 17631833 ); |
| 22 | if ( !defined( 'MWAI_TIMEOUT' ) ) { |
| 23 | define( 'MWAI_TIMEOUT', 60 * 5 ); |
| 24 | } |
| 25 | if ( !defined( 'MWAI_SSL_VERIFY' ) ) { |
| 26 | define( 'MWAI_SSL_VERIFY', false ); |
| 27 | } |
| 28 | define( 'MWAI_FALLBACK_MODEL', 'gpt-5.5' ); |
| 29 | define( 'MWAI_FALLBACK_MODEL_FAST', 'gpt-5-mini' ); |
| 30 | define( 'MWAI_FALLBACK_MODEL_VISION', 'gpt-5-mini' ); |
| 31 | define( 'MWAI_FALLBACK_MODEL_JSON', 'gpt-5-mini' ); |
| 32 | define( 'MWAI_FALLBACK_MODEL_IMAGES', 'gpt-image-1.5' ); |
| 33 | define( 'MWAI_FALLBACK_MODEL_AUDIO', 'whisper-1' ); |
| 34 | define( 'MWAI_FALLBACK_MODEL_EMBEDDINGS', 'text-embedding-3-small' ); |
| 35 | |
| 36 | require_once( MWAI_PATH . '/classes/init.php' ); |
| 37 | |
| 38 | add_filter( 'mwai_ai_exception', function ( $exception ) { |
| 39 | try { |
| 40 | // Remove the service prefix if present |
| 41 | if ( strpos( $exception, 'OpenAI:' ) === 0 ) { |
| 42 | $exception = trim( substr( $exception, strlen( 'OpenAI:' ) ) ); |
| 43 | } |
| 44 | |
| 45 | // If the remaining string looks like JSON, try to decode it |
| 46 | $json = json_decode( $exception, true ); |
| 47 | if ( is_array( $json ) && isset( $json['error']['message'] ) ) { |
| 48 | $exception = $json['error']['message']; |
| 49 | } |
| 50 | |
| 51 | if ( strpos( $exception, 'OpenAI' ) !== false ) { |
| 52 | if ( strpos( $exception, 'API URL was not found' ) !== false ) { |
| 53 | return "Received the 'API URL was not found' error from OpenAI. This actually means that your OpenAI account has not been enabled for the Chat API. You need to either add some credits to OpenAI account, or link a credit card to it."; |
| 54 | } |
| 55 | } |
| 56 | return $exception; |
| 57 | } |
| 58 | catch ( Exception $e ) { |
| 59 | error_log( $e->getMessage() ); |
| 60 | } |
| 61 | return $exception; |
| 62 | } ); |
| 63 |