PluginProbe
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services / 5.0.9
WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services v5.0.9
8.7.8 8.7.7 8.7.6 8.7.5 8.7.4 8.7.3 8.7.2 8.7.1 8.7.0 8.6.9 8.6.8 8.6.7 8.6.6 8.6.5 8.6.4 8.6.2 8.6.1 8.6.0 8.5.9 8.5.8 8.5.7 8.5.6 8.5.5 8.5.4 8.5.3 All 534 releases
chatbot / includes / openai / admin / settings.php

settings.php in WPBot – AI ChatBot for Live Support, Lead Generation, WordPress Automation, AI Services 5.0.9, at includes/openai/admin/settings.php

219 lines 19.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <div class="<?php esc_attr_e( 'row g-0','wpbot');?>">
2 <div class="<?php esc_attr_e( 'col-sm-10','wpbot');?>">
3 <div class="<?php esc_attr_e( 'form-check form-switch my-4','wpbot');?>">
4 <input class="<?php esc_attr_e( 'form-check-input','wpbot');?>" type="checkbox" <?php echo (get_option( 'ai_enabled') == 1) ? esc_attr( 'checked','wpbot') :'';?> role="switch" value="" id="<?php esc_attr_e( 'is_ai_enabled','wpbot'); ?>">
5 <label class="<?php esc_attr_e( 'form-check-label','wpbot');?>" for="<?php esc_attr_e( 'is_ai_enabled','wpbot'); ?>">
6 <?php esc_html_e( 'Enable Open AI','wpbot'); ?>
7 </label>
8 </div>
9 <div class="<?php esc_attr_e( 'form-check form-switch my-4','wpbot');?>">
10 <input class="<?php esc_attr_e( 'form-check-input','wpbot');?>" type="checkbox" <?php echo (get_option( 'ai_only_mode') == 1) ? esc_attr( 'checked','wpbot') :'';?> role="switch" value="" id="<?php esc_attr_e( 'is_ai_only_mode','wpbot');?>">
11 <label class="<?php esc_attr_e( 'form-check-label','wpbot');?>" for="<?php esc_attr_e( 'is_ai_only_mode','wpbot');?>">
12 <?php esc_html_e( 'Enable OpenAI only mode and hide other chatBot features','wpbot');?>
13 </label>
14 </div>
15 <div class="<?php esc_attr_e( 'mb-3','wpbot');?>">
16 <label for="<?php esc_attr_e( 'api_key','wpbot');?>" class="<?php esc_attr_e( 'form-label','wpbot');?>"><?php esc_html_e( 'Api key','wpbot');?></label>
17 <input type="text" class="<?php esc_attr_e( 'form-control','wpbot');?>" id="<?php esc_attr_e( 'api_key','wpbot');?>" name="api_key" placeholder="Api key" value="<?php esc_attr_e(get_option( 'open_ai_api_key'),'wpbot'); ?>">
18 </div>
19 <div class="<?php esc_attr_e( 'mb-3','wpbot');?>">
20 <label for="<?php esc_attr_e( 'max_tokens','wpbot');?>" class="<?php esc_attr_e( 'form-label','wpbot');?>"><?php esc_html_e( 'Max tokens (0-4000) Depending on the model','wpbot');?></label>
21 <input id="<?php esc_attr_e( 'max_tokens','wpbot');?>" class="<?php esc_attr_e( 'form-control','wpbot');?>" type="text" name="max_tokens" value="<?php esc_attr_e(get_option( 'openai_max_tokens'),'wpbot'); ?>">
22 </div>
23 <div class="<?php esc_attr_e( 'mb-3','wpbot');?>">
24 <div class="<?php esc_attr_e( 'row gx-0','wpbot');?>">
25 <div class="<?php esc_attr_e( 'col-8','wpbot');?>">
26 <label for="<?php esc_attr_e( 'temperature','wpbot');?>" class="<?php esc_attr_e( 'form-label','wpbot');?>"><?php esc_html_e( 'Temperature','wpbot');?></label>
27 </div>
28 <div class="<?php esc_attr_e( 'col-4 me-auto text-end','wpbot');?>">
29 <span name="temperatureout" id="<?php esc_attr_e( 'temperatureout','wpbot');?>" ><?php echo esc_html(get_option( 'openai_temperature')); ?></span></div>
30 </div>
31 <input id="<?php esc_attr_e( 'temperature','wpbot');?>" type="range" class="<?php esc_attr_e( 'form-range','wpbot');?>" min="0" max="1" step="0.01" name="temperature" value="<?php esc_attr_e(get_option( 'openai_temperature'),'wpbot'); ?>" onchange="updateTemp(this.value);" />
32 <label class="<?php esc_attr_e( 'mb-3','wpbot');?>">
33 <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','wpbot');?></small>
34 </label>
35 <span name="temperatureout" id="<?php esc_attr_e( 'temperatureout','wpbot');?>" ><?php echo esc_html(get_option( 'openai_temperature')); ?></span>
36 </div>
37 <div class="<?php esc_attr_e( 'mb-3','wpbot');?>">
38 <div class="<?php esc_attr_e( 'row gx-0','wpbot');?>"><div class="<?php esc_attr_e( 'col-8','wpbot');?>"><label for="<?php esc_attr_e( 'presence_penalty','wpbot');?>" class="<?php esc_attr_e( 'form-label','wpbot');?>"><?php esc_html_e( 'Presence Penalty','wpbot');?></label></div><div class="<?php esc_attr_e( 'col-4 me-auto text-end','wpbot');?>"><span id="<?php esc_attr_e( 'presence_penalty_out','wpbot');?>" ><?php echo esc_html(get_option( 'presence_penalty')); ?></span></div></div>
39 <input id="<?php esc_attr_e( 'presence_penalty','wpbot');?>" type="range" class="<?php esc_attr_e( 'form-range','wpbot');?>" min="-2" max="2" step="0.1" name="presence_penalty" value="<?php esc_attr_e(get_option( 'presence_penalty'),'wpbot'); ?>">
40 <p class="<?php esc_attr_e( 'mb-3','wpbot');?>"><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.','wpbot');?></small></p>
41 </div>
42 <div class="<?php esc_attr_e( 'mb-3','wpbot');?>">
43 <div class="<?php esc_attr_e( 'row gx-0','wpbot');?>"><div class="<?php esc_attr_e( 'col-8','wpbot');?>"><label for="<?php esc_attr_e( 'frequency_penalty','wpbot');?>" class="<?php esc_attr_e( 'form-label','wpbot');?>"><?php esc_html_e( 'Frequency penalty','wpbot');?></label></div><div class="<?php esc_attr_e( 'col-4 me-auto text-end','wpbot');?>"><span id="<?php esc_attr_e( 'frequency_penalty_out','wpbot');?>" ><?php esc_attr_e(get_option( 'frequency_penalty'),'wpbot'); ?></span></div></div>
44 <input id="<?php esc_attr_e( 'frequency_penalty','wpbot');?>" type="range" class="<?php esc_attr_e( 'form-range','wpbot');?>" min="-2" max="2" step="0.1" name="frequency_penalty" value="<?php esc_attr_e(get_option( 'frequency_penalty'),'wpbot'); ?>">
45 <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.','wpbot');?></small></label>
46 </div>
47
48 <div class="<?php esc_attr_e( 'mb-3','wpbot');?>">
49 <label for="<?php esc_attr_e( 'max_tokens','wpbot');?>" id="<?php esc_attr_e( 'openai_engines','wpbot');?>" class="<?php esc_attr_e( 'form-label','wpbot');?>"><?php esc_html_e( 'Open AI model','wpbot');?></label>
50 <select class="<?php esc_attr_e( 'form-select','wpbot');?>" aria-label="Default select example" name="openai_engines" id="<?php esc_attr_e( 'openai_engines','wpbot');?>">
51 <option <?php echo ((get_option( 'openai_engines') == '') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Please select Engines','wpbot');?></option>
52
53 <option value="<?php esc_attr_e( 'gpt-4','wpbot'); ?>" <?php echo ((get_option( 'openai_engines') == 'gpt-4') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'GPT-4','wpbot');?></option>
54 <option value="<?php esc_attr_e( 'gpt-3.5-turbo','wpbot'); ?>" <?php echo ((get_option( 'openai_engines') == 'gpt-3.5-turbo') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'GPT-3 turbo','wpbot'); ?></option>
55 <option value="<?php esc_attr_e( 'text-davinci-003','wpbot'); ?>" <?php echo ((get_option( 'openai_engines') == 'text-davinci-003') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Davinci (GPT-3 model)','wpbot');?></option>
56 <option value="<?php esc_attr_e( 'text-davinci-001','wpbot'); ?>" <?php echo ((get_option( 'openai_engines') == 'text-davinci-001') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Davinci','wpbot');?></option>
57 <option value="<?php esc_attr_e( 'text-ada-001','wpbot'); ?>" <?php echo ((get_option( 'openai_engines') == 'text-ada-001') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Ada','wpbot');?></option>
58 <option value="<?php esc_attr_e( 'text-curie-001','wpbot'); ?>" <?php echo ((get_option( 'openai_engines') == 'text-curie-001') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Curie','wpbot');?></option>
59 <option value="<?php esc_attr_e( 'text-babbage-001','wpbot'); ?>" <?php echo ((get_option( 'openai_engines') == 'text-babbage-001') ? esc_attr('selected') : '' ); ?>><?php esc_html_e( 'Babbag','wpbot');?></option>
60 </select>
61 </div>
62
63 <div class="<?php esc_attr_e( 'mb-3','wpbot');?>">
64 <label for="<?php esc_attr_e( 'qcld_openai_include_keyword','wpbot');?>"><?php esc_attr_e( 'Connect to OpenAI only when user query includes one of the following Keywords','wpbot');?></label>
65 <textarea type="text" class="<?php esc_attr_e( 'form-control','wpbot');?>" id="<?php esc_attr_e( 'qcld_openai_include_keyword','wpbot');?>"><?php echo esc_attr( get_option( 'openai_include_keyword')); ?></textarea>
66 </div>
67 <div class="<?php esc_attr_e( 'mb-3','wpbot');?>">
68 <label for="<?php esc_attr_e( 'qcld_openai_exclude_keyword','wpbot');?>"><?php esc_attr_e( 'Connect to OpenAI only when user query does NOT include one of the following Keywords','wpbot');?></label>
69 <textarea type="text" class="<?php esc_attr_e( 'form-control','wpbot');?>" id="<?php esc_attr_e( 'qcld_openai_exclude_keyword','wpbot');?>"><?php echo esc_attr( get_option( 'openai_exclude_keyword')); ?></textarea>
70 </div>
71 <div class="<?php esc_attr_e( 'mb-3','wpbot');?>">
72 <div class="<?php esc_attr_e( 'form-check form-switch my-4','wpbot');?>">
73 <input class="<?php esc_attr_e( 'form-check-input','wpbot');?>" type="checkbox" <?php echo (get_option( 'qcld_openai_relevant_enabled') == 1) ? esc_attr( 'checked','wpbot') :'';?> role="switch" value="" id="<?php esc_attr_e( 'is_relevant_enabled','wpbot'); ?>">
74 <label class="<?php esc_attr_e( 'form-check-label','wpbot');?>" for="<?php esc_attr_e( 'is_relevant_enabled','wpbot'); ?>">
75 <?php esc_html_e( 'Ask OpenAI to reply when question is relevant to above Keywords (Enabling this option will improve accuracy but it will use OpenAI Tokens)'); ?>
76 </label>
77 </div>
78 </div>
79 <div class="<?php esc_attr_e( 'mb-3','wpbot');?>">
80 <div class="">
81 <label><?php esc_html_e('Conversation continuity Only works in promt Q/A, Chat and friend chat'); ?></label>
82 </div>
83 <div class="<?php esc_attr_e( 'form-check form-switch my-4','wpbot');?>">
84 <input class="<?php esc_attr_e( 'form-check-input','wpbot');?>" type="checkbox" <?php echo (get_option( 'conversation_continuity') == 1) ? esc_attr( 'checked') : '';?> role="switch" value="" id="<?php esc_attr_e( 'conversation_continuity','wpbot');?>">
85 <label class="<?php esc_attr_e( 'form-check-label','wpbot');?>" for="<?php esc_attr_e( 'conversation_continuity','wpbot');?>"><?php esc_html_e( 'Enable conversation continuity','wpbot'); ?></label>
86 </div>
87 </div>
88 <div class="<?php esc_attr_e( 'mb-3','wpbot');?>">
89 <label for="<?php esc_attr_e( 'qcld_openai_custom_model','wpbot');?>" class="<?php esc_attr_e( 'form-label','wpbot');?>"><?php esc_html_e( 'Custom Fine Tuned Model','wpbot');?></label>
90 <input id="<?php esc_attr_e( 'qcld_openai_custom_model','wpbot');?>" class="<?php esc_attr_e( 'form-control','wpbot');?>" type="text" name="qcld_openai_custom_model" value="<?php echo esc_attr( get_option( 'qcld_openai_custom_model')); ?>">
91 <label><small><?php esc_html_e( 'Pick your custom model from fine tune list','wpbot');?></small></label>
92 </div>
93 <div class="<?php esc_attr_e( 'mb-3','wpbot');?>">
94
95 <label for="<?php esc_attr_e( 'qcld_openai_prompt','wpbot');?>" class="<?php esc_attr_e( 'form-label','wpbot');?>"><?php esc_html_e( 'Select Prompt','wpbot');?></label>
96 <select class="<?php esc_attr_e( 'form-select','wpbot');?>" aria-label="Default select example" name="qcld_openai_prompt" id="<?php esc_attr_e( 'qcld_openai_prompt','wpbot');?>">
97 <option <?php echo ((get_option( 'qcld_openai_prompt') == '') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Please select prompt','wpbot');?></option>
98 <option value="<?php esc_attr_e('q_and_a','wpbot'); ?>" <?php echo ((get_option( 'qcld_openai_prompt') == 'q_and_a') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Q & A','wpbot');?></option>
99 <option value="<?php esc_attr_e('chat','wpbot'); ?>" <?php echo ((get_option( 'qcld_openai_prompt') == 'chat') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Chat','wpbot');?></option>
100 <option value="<?php esc_attr_e('friend_chat','wpbot'); ?>" <?php echo ((get_option( 'qcld_openai_prompt') == 'friend_chat') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Friend Chat','wpbot');?></option>
101 <option value="<?php esc_attr_e('grammar_correction','wpbot'); ?>" <?php echo ((get_option( 'qcld_openai_prompt') == 'grammar_correction') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Grammar correction','wpbot');?></option>
102 <option value="<?php esc_attr_e('marv_sarcastic_chatbot','wpbot'); ?>" <?php echo ((get_option( 'qcld_openai_prompt') == 'marv_sarcastic_chatbot') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Marv the sarcastic chat bot','wpbot');?></option>
103 <option value="<?php esc_attr_e('micro_horror','wpbot'); ?>" <?php echo ((get_option( 'qcld_openai_prompt') == 'micro_horror') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Two-Sentence Horror Story:','wpbot');?></option>
104 <option value="<?php esc_attr_e('write_poem','wpbot'); ?>" <?php echo ((get_option( 'qcld_openai_prompt') == 'write_poem') ? esc_attr('selected') : '') ?>><?php esc_html_e( 'Write a poem (in English)','wpbot');?></option>
105 <option value="<?php esc_attr_e('translated_qa','wpbot'); ?>" <?php echo ((get_option( 'qcld_openai_prompt') == 'translated_qa') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Translated Question Answer on your site language','wpbot');?></option>
106 <option value="<?php esc_attr_e('any_command','wpbot'); ?>" <?php echo ((get_option( 'qcld_openai_prompt') == 'any_command') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Any command','wpbot');?></option>
107 <option value="<?php esc_attr_e('custom_prompt','wpbot'); ?>" <?php echo ((get_option( 'qcld_openai_prompt') == 'custom_prompt') ? esc_attr('selected') : '') ; ?>><?php esc_html_e( 'Custom prompt will be appended before the user`s queries','wpbot');?></option>
108 </select>
109 <div id="<?php esc_attr_e( 'custom_prompt_wrapper','wpbot');?>">
110 <input type="hidden" id="<?php esc_attr_e( 'custom_promt_value','wpbot');?>" value="<?php esc_attr_e(get_option('qcld_openai_prompt_custom'),'wpbot'); ?>"/>
111 </div>
112 <p class="<?php esc_attr_e( 'mb-3','wpbot');?>"><small><?php esc_html_e( 'Please Select a prompt. The default value of the prompt is Q&A','wpbot');?></small></p>
113 </div>
114 <div class="<?php esc_attr_e( 'mb-3','wpbot');?>">
115 <!-- Customized by Kadir on 05-12-2023 -->
116 <a class="<?php esc_attr_e( 'btn btn-success hidden','wpbot');?>" id="<?php esc_attr_e( 'save_setting','wpbot');?>"><?php esc_html_e( 'Save settings','wpbot');?></a>
117 <a href="#" class="<?php esc_attr_e( 'btn btn-success','wpbot');?>" id="<?php esc_attr_e( 'settingsModalButtton','wpbot');?>"><?php esc_html_e( 'Save Settings','wpbot');?></a>
118 <!-- Ends: Customized by Kadir on 05-12-2023 -->
119 </div>
120 <div class="<?php esc_attr_e( 'alert alert-danger','wpbot');?>">
121 <p> <?php echo esc_html('**If OpenAI is not responding back and the bot is just loading, then likely you hit your OpenAI usage limit. Add a'); ?> <a href="https://platform.openai.com/account/billing/overview"><?php echo esc_html('billing detail'); ?></a> <?php echo esc_html('(Credit Card) and increase the Usage limit.'); ?></p>
122 </div>
123 </div>
124 </div>
125
126 <!-- Customized by Kadir on 05-12-2023 -->
127
128 <!-- Modal: OPENAI ALERT - If site search is ON -->
129 <div class="modal fade" id="SiteSearchDecision" tabindex="-1" role="dialog" aria-labelledby="SiteSearchDecisionLabel" aria-hidden="true">
130 <div class="modal-dialog" role="document">
131 <div class="modal-content">
132 <div class="modal-header">
133 <h3 class="modal-title" id="SiteSearchDecisionLabel">OpenAI Alert</h3>
134 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
135 <span aria-hidden="true">&times;</span>
136 </button>
137 </div>
138 <div class="modal-body">
139 <p class="alert alert-info">
140 Currently SITE SEARCH is turned ON. As per our search algorithm SITE SEARCH gets priority over the AI models.
141 <br><br><strong>Do you want to disable SITE SEARCH so that all responses come from OpenAI?</strong>
142 </p>
143 </div>
144 <div class="modal-footer text-center" style="text-align: center!important;">
145 <a class="<?php esc_attr_e( 'btn btn-success','wpbot');?>" id="<?php esc_attr_e( 'save_setting_disable_ss','wpbot');?>"><?php esc_html_e( 'Proceed with Disabling Site Search','wpbot');?></a>
146 <a class="<?php esc_attr_e( 'btn btn-primary','wpbot');?>" id="<?php esc_attr_e( 'save_setting','wpbot');?>"><?php esc_html_e( 'Proceed without Disabling Site Search','wpbot');?></a>
147 </div>
148 </div>
149 </div>
150 </div>
151
152 <!-- Modal:OPENAI ALERT - If API Key value is Empty -->
153 <div class="modal fade" tabindex="-1" role="dialog" id="apiKeyEmptyModal" >
154 <div class="modal-dialog" role="document">
155 <div class="modal-content">
156 <div class="modal-header">
157 <h3 class="modal-title">OpenAI Alert</h3>
158 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
159 <span aria-hidden="true">&times;</span>
160 </button>
161 </div>
162 <div class="modal-body">
163 <p class="alert alert-danger mb-0">You enabled OpenAI. But the API key is empty!</p>
164 <p class="alert alert-info mt-0"><strong>Please set a valid API key.</strong></p>
165 </div>
166 <div class="modal-footer">
167 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
168 </div>
169 </div>
170 </div>
171 </div>
172
173 <?php
174
175 $isSiteSearchOn = get_option('disable_wp_chatbot_site_search');
176
177 if( $isSiteSearchOn == "" ){
178 $isSiteSearchOn = 0;
179 }
180
181 ?>
182
183 <script>
184
185 jQuery(document).ready(function($){
186
187 apiKeyValue = $("#api_key").val();
188
189 $("#api_key").on('change', function(){
190 apiKeyValue = this.value;
191 });
192
193 siteSearchValue = <?php echo $isSiteSearchOn; ?>;
194
195 $("#settingsModalButtton").click(function(e){
196
197 e.preventDefault();
198
199 if( $("#is_ai_enabled").is(':checked') && apiKeyValue.trim() == "" ){
200 $('#apiKeyEmptyModal').modal();
201 }
202 else if( $("#is_ai_enabled").is(':checked') && apiKeyValue.trim() != "" && $("#is_ai_only_mode").is(':checked') ){
203 $("#save_setting").trigger("click");
204 }
205 else if($("#is_ai_enabled").is(':checked') && apiKeyValue.trim() != "" && siteSearchValue == 0){
206 $('#SiteSearchDecision').modal();
207 }
208 else{
209 $("#save_setting").trigger("click");
210 }
211
212 });
213 });
214
215
216 </script>
217
218 <!-- Ends: Customized by Kadir on 05-12-2023 -->
219