| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || exit; |
| 3 |
|
| 4 |
add_action( 'init', 'ultp_chatgpt_init' ); |
| 5 |
function ultp_chatgpt_init() { |
| 6 |
if ( ultimate_post()->get_setting( 'ultp_chatgpt' ) == 'true' ) { |
| 7 |
add_filter( 'ultp_settings', 'get_chatgpt_settings', 10, 1 ); |
| 8 |
} |
| 9 |
} |
| 10 |
|
| 11 |
function get_chatgpt_settings( $config ) { |
| 12 |
$arr = array( |
| 13 |
'ultp_chatgpt' => array( |
| 14 |
'label' => __( 'ChatGPT', 'ultimate-post' ), |
| 15 |
'attr' => array( |
| 16 |
'chatgpt_heading' => array( |
| 17 |
'type' => 'heading', |
| 18 |
'label' => __( 'ChatGPT Settings', 'ultimate-post' ), |
| 19 |
), |
| 20 |
'chatgpt_secret_key' => array( |
| 21 |
'type' => 'text', |
| 22 |
'label' => __( 'OpenAI API Secret Key', 'ultimate-post' ), |
| 23 |
'desc' => __( 'For using ChatGPT addon, you have to add your OpenAI secret key.', 'ultimate-post' ), |
| 24 |
'link' => __( 'https://platform.openai.com/account/api-keys' ), |
| 25 |
'linkText' => __( 'Get key.', 'ultimate-post' ), |
| 26 |
), |
| 27 |
'chatgpt_model' => array( |
| 28 |
'type' => 'select', |
| 29 |
'label' => __( 'OpenAI Model', 'ultimate-post' ), |
| 30 |
'desc' => __( 'Choose your preferable OpenAI model', 'ultimate-post' ), |
| 31 |
'options' => array( |
| 32 |
'gpt-3.5-turbo' => 'gpt-3.5-turbo', |
| 33 |
'text-davinci-002' => 'text-davinci-002', |
| 34 |
'text-davinci-003' => 'text-davinci-003', |
| 35 |
'gpt-4' => 'gpt-4', |
| 36 |
), |
| 37 |
'default' => 'gpt-3.5-turbo', |
| 38 |
), |
| 39 |
'chatgpt_response_time' => array( |
| 40 |
'type' => 'number', |
| 41 |
'label' => __( 'Response Time', 'ultimate-post' ), |
| 42 |
'desc' => __( 'Choose your preferable OpenAI response time', 'ultimate-post' ), |
| 43 |
'default' => 60, |
| 44 |
), |
| 45 |
'chatgpt_max_tokens' => array( |
| 46 |
'type' => 'number', |
| 47 |
'label' => __( 'Max Tokens', 'ultimate-post' ), |
| 48 |
'desc' => __( 'Choose your preferable OpenAI max Number of Tokens to be generated by ChatGPT', 'ultimate-post' ), |
| 49 |
'default' => 400, |
| 50 |
), |
| 51 |
), |
| 52 |
), |
| 53 |
); |
| 54 |
return array_merge( $config, $arr ); |
| 55 |
} |
| 56 |
|