| @@ -1,107 +1,104 @@ | ||
| 1 | -<!-- //not used --> | |
| 2 | -<div class="qcl-openai"> | |
| 3 | - <div class="row gx-0"> | |
| 4 | - <div class="col-xs-12"> | |
| 5 | - <div class="card admin-maxwith qcld-openai-main-box"> | |
| 6 | - <div class="card-header bg-dark text-white py-sm-4 border-0"> | |
| 7 | - | |
| 8 | - | |
| 9 | - | |
| 10 | - <div class="row"> | |
| 11 | - <div class="col-auto me-auto"> | |
| 12 | - <h4> | |
| 13 | - <?php | |
| 14 | - if (!defined('ABSPATH')) exit; // Exit if accessed directly | |
| 15 | - esc_html_e( 'OpenAI Settings','chatbot'); | |
| 16 | - ?> | |
| 17 | - </h4> | |
| 18 | - </div> | |
| 19 | - <div class="col-auto"> | |
| 20 | - <!-- <img class="img-fluid" src="<?php //echo esc_url(QCLD_openai_addon_PLUGIN_URL.'image/logo.jpg'); ?>"/> --> | |
| 21 | - </div> | |
| 22 | - </div> | |
| 23 | - </div> | |
| 24 | - <div class="card-body p-sm-0"> | |
| 25 | - <div class="row g-0"> | |
| 26 | - <div class="p-sm-3 bg-dark rl-col-custom"></div> | |
| 27 | - <div class="col-sm-10"> | |
| 28 | - <div class="form-check form-switch my-4"> | |
| 29 | - <input class="form-check-input" type="checkbox" <?php echo esc_attr( (get_option( 'ai_enabled') == 1) ? 'checked' :'' );?> role="switch" value="" id="is_ai_enabled"> | |
| 30 | - <label class="form-check-label" for="is_ai_enabled"> | |
| 31 | - <?php esc_html_e( 'Enable OpenAI','chatbot');?> | |
| 32 | - </label> | |
| 33 | - </div> | |
| 34 | - <div class="form-check form-switch my-4"> | |
| 35 | - <input class="form-check-input" type="checkbox" <?php echo esc_attr( (get_option( 'ai_only_mode') == 1) ? 'checked' :'');?> role="switch" value="" id="is_ai_only_mode"> | |
| 36 | - <label class="form-check-label" for="is_ai_only_mode"> | |
| 37 | - <?php esc_html_e( 'Enable OpenAI only mode and hide other chatBot features','chatbot');?> | |
| 38 | - </label> | |
| 39 | - </div> | |
| 40 | - <div class="mb-3"> | |
| 41 | - <label for="api_key" class="form-label"><?php esc_html_e( 'Api key','chatbot');?></label> | |
| 42 | - <input type="text" class="form-control" id="api_key" name="api_key" placeholder="Api key" value="<?php echo esc_attr( get_option( 'open_ai_api_key') ); ?>"> | |
| 43 | - </div> | |
| 44 | - <div class="mb-3"> | |
| 45 | - <label for="max_tokens" class="form-label"><?php esc_html_e( 'Max tokens (0-4000) Depending on the model','chatbot');?></label> | |
| 46 | - <input id="max_tokens" class="form-control" type="text" name="max_tokens" value="<?php echo esc_attr( get_option( 'openai_max_tokens') ); ?>"> | |
| 47 | - </div> | |
| 48 | - <div class="mb-3"> | |
| 49 | - <div class="row gx-0"><div class="col-8"><label for="temperature" class="form-label"><?php esc_html_e( 'Temperature','chatbot');?></label></div><div class="col-4 me-auto text-end"><span name="temperatureout" id="temperatureout" ><?php echo esc_html( get_option( 'openai_temperature') ); ?></span></div></div> | |
| 50 | - <input id="temperature" type="range" class="form-range" min="0" max="1" step="0.01" name="temperature" value="<?php echo esc_attr( get_option( 'openai_temperature') ); ?>" onchange="updateTemp(this.value);" /> | |
| 51 | - <label class="mb-3"><small><?php esc_html_e( 'Temperature is a value between 0 and 1 that essentially lets you control how confident the model should be when making these predictions','chatbot');?></small></label> | |
| 52 | - <span name="temperatureout" id="temperatureout" ><?php // echo get_option( 'openai_temperature'); ?></span> | |
| 53 | - </div> | |
| 54 | - <div class="mb-3"> | |
| 55 | - <div class="row gx-0"><div class="col-8"><label for="presence_penalty" class="form-label"><?php esc_html_e( 'Presence Penalty','chatbot');?></label></div><div class="col-4 me-auto text-end"><span id="presence_penalty_out" ><?php echo esc_html( get_option( 'presence_penalty') ); ?></span></div></div> | |
| 56 | - <input id="presence_penalty" type="range" class="form-range" min="-2" max="2" step="0.1" name="presence_penalty" value="<?php echo esc_attr( get_option( 'presence_penalty') ); ?>"> | |
| 57 | - <p class="mb-3"><small><?php esc_html_e( 'Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics.','chatbot');?></small></p> | |
| 58 | - </div> | |
| 59 | - <div class="mb-3"> | |
| 60 | - <div class="row gx-0"><div class="col-8"><label for="frequency_penalty" class="form-label"><?php esc_html_e( 'Frequency penalty','chatbot');?></label></div><div class="col-4 me-auto text-end"><span id="frequency_penalty_out" ><?php echo esc_html( get_option( 'frequency_penalty') ); ?></span></div></div> | |
| 61 | - <input id="frequency_penalty" type="range" class="form-range" min="-2" max="2" step="0.1" name="frequency_penalty" value="<?php echo esc_attr( get_option( 'frequency_penalty') ); ?>"> | |
| 62 | - <label><small><?php esc_html_e( 'Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.','chatbot');?></small></label> | |
| 63 | - </div> | |
| 64 | - | |
| 65 | - <div class="mb-3"> | |
| 66 | - <label for="max_tokens" id="openai_engines" class="form-label"><?php esc_html_e( 'Engines','chatbot');?></label> | |
| 67 | - <select class="form-select" aria-label="Default select example" name="openai_engines" id="openai_engines"> | |
| 68 | - <option <?php echo esc_attr( ((get_option( 'openai_engines') == '') ? 'selected' : '') ); ?>><?php esc_html_e( 'Please select Engines','chatbot');?></option> | |
| 69 | - <option value="text-davinci-003" <?php echo esc_attr( ((get_option( 'openai_engines') == 'text-davinci-003') ? 'selected' : '') ); ?>><?php esc_html_e( 'Davinci (GPT-3 model)','chatbot');?></option> | |
| 70 | - <option value="text-davinci-001" <?php echo esc_attr( ((get_option( 'openai_engines') == 'text-davinci-001') ? 'selected' : '') ); ?>><?php esc_html_e( 'Davinci','chatbot');?></option> | |
| 71 | - <option value="text-ada-001" <?php echo esc_attr( ((get_option( 'openai_engines') == 'text-ada-001') ? 'selected' : '') ); ?>><?php esc_html_e( 'Ada','chatbot');?></option> | |
| 72 | - <option value="text-curie-001" <?php echo esc_attr( ((get_option( 'openai_engines') == 'text-curie-001') ? 'selected' : '') ); ?>><?php esc_html_e( 'Curie','chatbot');?></option> | |
| 73 | - <option value="text-babbage-001" <?php echo esc_attr( ((get_option( 'openai_engines') == 'text-babbage-001') ? 'selected' : '' ) ); ?>><?php esc_html_e( 'Babbag','chatbot');?></option> | |
| 74 | - </select> | |
| 75 | - </div> | |
| 76 | - | |
| 77 | - <div class="mb-3"> | |
| 78 | - | |
| 79 | - <label for="qcld_openai_prompt" class="form-label"><?php esc_html_e( 'Select Prompt','chatbot');?></label> | |
| 80 | - <select class="form-select" aria-label="Default select example" name="qcld_openai_prompt" id="qcld_openai_prompt"> | |
| 81 | - <option <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == '') ? 'selected' : '') ); ?>><?php esc_html_e( 'Please select prompt','chatbot');?></option> | |
| 82 | - <option value="q_and_a" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'q_and_a') ? 'selected' : '') ); ?>><?php esc_html_e( 'Q & A','chatbot');?></option> | |
| 83 | - <option value="chat" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'chat') ? 'selected' : '') ); ?>><?php esc_html_e( 'Chat','chatbot');?></option> | |
| 84 | - <option value="friend_chat" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'friend_chat') ? 'selected' : '') ); ?>><?php esc_html_e( 'Friend Chat','chatbot');?></option> | |
| 85 | - <option value="grammar_correction" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'grammar_correction') ? 'selected' : '') ); ?>><?php esc_html_e( 'Grammar correction','chatbot');?></option> | |
| 86 | - <option value="marv_sarcastic_chatbot" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'marv_sarcastic_chatbot') ? 'selected' : '') ); ?>><?php esc_html_e( 'Marv the sarcastic chat bot','chatbot');?></option> | |
| 87 | - <option value="micro_horror" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'micro_horror') ? 'selected' : '') ); ?>><?php esc_html_e( 'Two-Sentence Horror Story:','chatbot');?></option> | |
| 88 | - <option value="write_poem" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'write_poem') ? 'selected' : '') ); ?>><?php esc_html_e( 'Write a poem (in English)','chatbot');?></option> | |
| 89 | - <option value="any_command" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'any_command') ? 'selected' : '') ); ?>><?php esc_html_e( 'Any command','chatbot');?></option> | |
| 90 | - <option value="custom_prompt" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'custom_prompt') ? 'selected' : '') ); ?>><?php esc_html_e( 'Custom prompt will be appended before the user`s queries','chatbot');?></option> | |
| 91 | - </select> | |
| 92 | - <div id="custom_prompt_wrapper"> | |
| 93 | - <input type="hidden" id="custom_promt_value" value="<?php echo esc_attr( get_option('qcld_openai_prompt_custom') ); ?>"/> | |
| 94 | - </div> | |
| 95 | - <p class="mb-3"><small><?php esc_html_e( 'Please Select a prompt. The default value of the prompt is Q&A','chatbot');?></small></p> | |
| 96 | - </div> | |
| 97 | - | |
| 98 | - <a class="btn btn-success" id="save_setting"><?php esc_html_e( 'Save settings','chatbot');?></a> | |
| 99 | - </div> | |
| 100 | - <div class="p-sm-3 bg-dark rl-col-custom ms-auto"></div> | |
| 101 | - </div> | |
| 102 | - <div class="card-footer bg-dark text-white py-sm-4 border-0"></div> | |
| 103 | - </div> | |
| 104 | - </div> | |
| 105 | - </div> | |
| 106 | -</div> | |
| 107 | - | |
| 1 | +<!-- //not used --> | |
| 2 | +<div class="qcl-openai"> | |
| 3 | + <div class="row gx-0"> | |
| 4 | + <div class="col-xs-12"> | |
| 5 | + <div class="card admin-maxwith qcld-openai-main-box"> | |
| 6 | + <div class="card-header bg-dark text-white py-sm-4 border-0"> | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + <div class="row"> | |
| 11 | + <div class="col-auto me-auto"> | |
| 12 | + <h4><?php | |
| 13 | +if (!defined('ABSPATH')) exit; // Exit if accessed directly | |
| 14 | +esc_html_e( 'OpenAI Settings','chatbot');?></h4> | |
| 15 | + </div> | |
| 16 | + <div class="col-auto"> | |
| 17 | + <!-- <img class="img-fluid" src="<?php //echo esc_url(QCLD_openai_addon_PLUGIN_URL.'image/logo.jpg'); ?>"/> --> | |
| 18 | + </div> | |
| 19 | + </div> | |
| 20 | + </div> | |
| 21 | + <div class="card-body p-sm-0"> | |
| 22 | + <div class="row g-0"> | |
| 23 | + <div class="p-sm-3 bg-dark rl-col-custom"></div> | |
| 24 | + <div class="col-sm-10"> | |
| 25 | + <div class="form-check form-switch my-4"> | |
| 26 | + <input class="form-check-input" type="checkbox" <?php echo esc_attr( (get_option( 'ai_enabled') == 1) ? 'checked' :'' );?> role="switch" value="" id="is_ai_enabled"> | |
| 27 | + <label class="form-check-label" for="is_ai_enabled"> | |
| 28 | + <?php esc_html_e( 'Enable OpenAI','chatbot');?> | |
| 29 | + </label> | |
| 30 | + </div> | |
| 31 | + <div class="form-check form-switch my-4"> | |
| 32 | + <input class="form-check-input" type="checkbox" <?php echo esc_attr( (get_option( 'ai_only_mode') == 1) ? 'checked' :'');?> role="switch" value="" id="is_ai_only_mode"> | |
| 33 | + <label class="form-check-label" for="is_ai_only_mode"> | |
| 34 | + <?php esc_html_e( 'Enable OpenAI only mode and hide other chatBot features','chatbot');?> | |
| 35 | + </label> | |
| 36 | + </div> | |
| 37 | + <div class="mb-3"> | |
| 38 | + <label for="api_key" class="form-label"><?php esc_html_e( 'Api key','chatbot');?></label> | |
| 39 | + <input type="text" class="form-control" id="api_key" name="api_key" placeholder="Api key" value="<?php echo esc_attr( get_option( 'open_ai_api_key') ); ?>"> | |
| 40 | + </div> | |
| 41 | + <div class="mb-3"> | |
| 42 | + <label for="max_tokens" class="form-label"><?php esc_html_e( 'Max tokens (0-4000) Depending on the model','chatbot');?></label> | |
| 43 | + <input id="max_tokens" class="form-control" type="text" name="max_tokens" value="<?php echo esc_attr( get_option( 'openai_max_tokens') ); ?>"> | |
| 44 | + </div> | |
| 45 | + <div class="mb-3"> | |
| 46 | + <div class="row gx-0"><div class="col-8"><label for="temperature" class="form-label"><?php esc_html_e( 'Temperature','chatbot');?></label></div><div class="col-4 me-auto text-end"><span name="temperatureout" id="temperatureout" ><?php echo esc_html( get_option( 'openai_temperature') ); ?></span></div></div> | |
| 47 | + <input id="temperature" type="range" class="form-range" min="0" max="1" step="0.01" name="temperature" value="<?php echo esc_attr( get_option( 'openai_temperature') ); ?>" onchange="updateTemp(this.value);" /> | |
| 48 | + <label class="mb-3"><small><?php esc_html_e( 'Temperature is a value between 0 and 1 that essentially lets you control how confident the model should be when making these predictions','chatbot');?></small></label> | |
| 49 | + <span name="temperatureout" id="temperatureout" ><?php // echo get_option( 'openai_temperature'); ?></span> | |
| 50 | + </div> | |
| 51 | + <div class="mb-3"> | |
| 52 | + <div class="row gx-0"><div class="col-8"><label for="presence_penalty" class="form-label"><?php esc_html_e( 'Presence Penalty','chatbot');?></label></div><div class="col-4 me-auto text-end"><span id="presence_penalty_out" ><?php echo esc_html( get_option( 'presence_penalty') ); ?></span></div></div> | |
| 53 | + <input id="presence_penalty" type="range" class="form-range" min="-2" max="2" step="0.1" name="presence_penalty" value="<?php echo esc_attr( get_option( 'presence_penalty') ); ?>"> | |
| 54 | + <p class="mb-3"><small><?php esc_html_e( 'Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model’s likelihood to talk about new topics.','chatbot');?></small></p> | |
| 55 | + </div> | |
| 56 | + <div class="mb-3"> | |
| 57 | + <div class="row gx-0"><div class="col-8"><label for="frequency_penalty" class="form-label"><?php esc_html_e( 'Frequency penalty','chatbot');?></label></div><div class="col-4 me-auto text-end"><span id="frequency_penalty_out" ><?php echo esc_html( get_option( 'frequency_penalty') ); ?></span></div></div> | |
| 58 | + <input id="frequency_penalty" type="range" class="form-range" min="-2" max="2" step="0.1" name="frequency_penalty" value="<?php echo esc_attr( get_option( 'frequency_penalty') ); ?>"> | |
| 59 | + <label><small><?php esc_html_e( 'Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model’s likelihood to repeat the same line verbatim.','chatbot');?></small></label> | |
| 60 | + </div> | |
| 61 | + | |
| 62 | + <div class="mb-3"> | |
| 63 | + <label for="max_tokens" id="openai_engines" class="form-label"><?php esc_html_e( 'Engines','chatbot');?></label> | |
| 64 | + <select class="form-select" aria-label="Default select example" name="openai_engines" id="openai_engines"> | |
| 65 | + <option <?php echo esc_attr( ((get_option( 'openai_engines') == '') ? 'selected' : '') ); ?>><?php esc_html_e( 'Please select Engines','chatbot');?></option> | |
| 66 | + <option value="text-davinci-003" <?php echo esc_attr( ((get_option( 'openai_engines') == 'text-davinci-003') ? 'selected' : '') ); ?>><?php esc_html_e( 'Davinci (GPT-3 model)','chatbot');?></option> | |
| 67 | + <option value="text-davinci-001" <?php echo esc_attr( ((get_option( 'openai_engines') == 'text-davinci-001') ? 'selected' : '') ); ?>><?php esc_html_e( 'Davinci','chatbot');?></option> | |
| 68 | + <option value="text-ada-001" <?php echo esc_attr( ((get_option( 'openai_engines') == 'text-ada-001') ? 'selected' : '') ); ?>><?php esc_html_e( 'Ada','chatbot');?></option> | |
| 69 | + <option value="text-curie-001" <?php echo esc_attr( ((get_option( 'openai_engines') == 'text-curie-001') ? 'selected' : '') ); ?>><?php esc_html_e( 'Curie','chatbot');?></option> | |
| 70 | + <option value="text-babbage-001" <?php echo esc_attr( ((get_option( 'openai_engines') == 'text-babbage-001') ? 'selected' : '' ) ); ?>><?php esc_html_e( 'Babbag','chatbot');?></option> | |
| 71 | + </select> | |
| 72 | + </div> | |
| 73 | + | |
| 74 | + <div class="mb-3"> | |
| 75 | + | |
| 76 | + <label for="qcld_openai_prompt" class="form-label"><?php esc_html_e( 'Select Prompt','chatbot');?></label> | |
| 77 | + <select class="form-select" aria-label="Default select example" name="qcld_openai_prompt" id="qcld_openai_prompt"> | |
| 78 | + <option <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == '') ? 'selected' : '') ); ?>><?php esc_html_e( 'Please select prompt','chatbot');?></option> | |
| 79 | + <option value="q_and_a" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'q_and_a') ? 'selected' : '') ); ?>><?php esc_html_e( 'Q & A','chatbot');?></option> | |
| 80 | + <option value="chat" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'chat') ? 'selected' : '') ); ?>><?php esc_html_e( 'Chat','chatbot');?></option> | |
| 81 | + <option value="friend_chat" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'friend_chat') ? 'selected' : '') ); ?>><?php esc_html_e( 'Friend Chat','chatbot');?></option> | |
| 82 | + <option value="grammar_correction" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'grammar_correction') ? 'selected' : '') ); ?>><?php esc_html_e( 'Grammar correction','chatbot');?></option> | |
| 83 | + <option value="marv_sarcastic_chatbot" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'marv_sarcastic_chatbot') ? 'selected' : '') ); ?>><?php esc_html_e( 'Marv the sarcastic chat bot','chatbot');?></option> | |
| 84 | + <option value="micro_horror" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'micro_horror') ? 'selected' : '') ); ?>><?php esc_html_e( 'Two-Sentence Horror Story:','chatbot');?></option> | |
| 85 | + <option value="write_poem" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'write_poem') ? 'selected' : '') ); ?>><?php esc_html_e( 'Write a poem (in English)','chatbot');?></option> | |
| 86 | + <option value="any_command" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'any_command') ? 'selected' : '') ); ?>><?php esc_html_e( 'Any command','chatbot');?></option> | |
| 87 | + <option value="custom_prompt" <?php echo esc_attr( ((get_option( 'qcld_openai_prompt') == 'custom_prompt') ? 'selected' : '') ); ?>><?php esc_html_e( 'Custom prompt will be appended before the user`s queries','chatbot');?></option> | |
| 88 | + </select> | |
| 89 | + <div id="custom_prompt_wrapper"> | |
| 90 | + <input type="hidden" id="custom_promt_value" value="<?php echo esc_attr( get_option('qcld_openai_prompt_custom') ); ?>"/> | |
| 91 | + </div> | |
| 92 | + <p class="mb-3"><small><?php esc_html_e( 'Please Select a prompt. The default value of the prompt is Q&A','chatbot');?></small></p> | |
| 93 | + </div> | |
| 94 | + | |
| 95 | + <a class="btn btn-success" id="save_setting"><?php esc_html_e( 'Save settings','chatbot');?></a> | |
| 96 | + </div> | |
| 97 | + <div class="p-sm-3 bg-dark rl-col-custom ms-auto"></div> | |
| 98 | + </div> | |
| 99 | + <div class="card-footer bg-dark text-white py-sm-4 border-0"></div> | |
| 100 | + </div> | |
| 101 | + </div> | |
| 102 | + </div> | |
| 103 | +</div> | |
| 104 | + | |