max_prompt_length options added. fixes #165
This commit is contained in:
parent
41d2405f2d
commit
6808e3a81f
5 changed files with 27 additions and 1 deletions
|
|
@ -634,5 +634,13 @@
|
||||||
"prefs_OptionText_placeholders_use_default_value_info": {
|
"prefs_OptionText_placeholders_use_default_value_info": {
|
||||||
"message": "If checked, the placeholders will be filled with the default values when no value is provided. Otherwise, the placeholders will be kept in place.",
|
"message": "If checked, the placeholders will be filled with the default values when no value is provided. Otherwise, the placeholders will be kept in place.",
|
||||||
"description": ""
|
"description": ""
|
||||||
|
},
|
||||||
|
"prefs_OptionText_max_prompt_length" : {
|
||||||
|
"message": "Max prompt length",
|
||||||
|
"description": ""
|
||||||
|
},
|
||||||
|
"prefs_OptionText_max_prompt_length_Info" : {
|
||||||
|
"message": "This is the maximum number of characters that can be used in a prompt. Otherwise, an error message will be displayed. The value is not editable for the ChatGPT Web Interface.",
|
||||||
|
"description": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -245,7 +245,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
||||||
prefs = checkScreenDimensions(prefs);
|
prefs = checkScreenDimensions(prefs);
|
||||||
//console.log(">>>>>>>>>>>>>>>> prefs: " + JSON.stringify(prefs));
|
//console.log(">>>>>>>>>>>>>>>> prefs: " + JSON.stringify(prefs));
|
||||||
taLog.log("[ThunderAI] Prompt length: " + promptText.length);
|
taLog.log("[ThunderAI] Prompt length: " + promptText.length);
|
||||||
if(promptText.length > 30000 ){
|
if(promptText.length > prefs.max_prompt_length){
|
||||||
// Prompt too long for ChatGPT
|
// Prompt too long for ChatGPT
|
||||||
browser.tabs.sendMessage(curr_tabId, { command: "promptTooLong" });
|
browser.tabs.sendMessage(curr_tabId, { command: "promptTooLong" });
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -33,4 +33,5 @@ export const prefs_default = {
|
||||||
dynamic_menu_force_enter: false,
|
dynamic_menu_force_enter: false,
|
||||||
dynamic_menu_order_alphabet: true,
|
dynamic_menu_order_alphabet: true,
|
||||||
placeholders_use_default_value: false,
|
placeholders_use_default_value: false,
|
||||||
|
max_prompt_length: 30000, // max string length for prompt
|
||||||
}
|
}
|
||||||
|
|
@ -220,6 +220,15 @@
|
||||||
</label>
|
</label>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><span>__MSG_prefs_OptionText_max_prompt_length__</span></td>
|
||||||
|
<td>
|
||||||
|
<label>
|
||||||
|
<input type="number" id="max_prompt_length" name="max_prompt_length" class="option-input" />
|
||||||
|
<br>__MSG_prefs_OptionText_max_prompt_length_Info__
|
||||||
|
</label>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width:20em"><label>
|
<td style="width:20em"><label>
|
||||||
<span>__MSG_Debug__</span>
|
<span>__MSG_Debug__</span>
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ async function restoreOptions() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showConnectionOptions() {
|
function showConnectionOptions() {
|
||||||
|
disable_MaxPromptLength();
|
||||||
let chatgpt_web_display = 'table-row';
|
let chatgpt_web_display = 'table-row';
|
||||||
let chatgpt_api_display = 'none';
|
let chatgpt_api_display = 'none';
|
||||||
let ollama_api_display = 'none';
|
let ollama_api_display = 'none';
|
||||||
|
|
@ -203,6 +204,12 @@ function warn_OpenAIComp_HostEmpty() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function disable_MaxPromptLength(){
|
||||||
|
let maxPromptLength = document.getElementById('max_prompt_length');
|
||||||
|
let conntype_select = document.getElementById("connection_type");
|
||||||
|
maxPromptLength.disabled = (conntype_select.value === "chatgpt_web");
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
document.addEventListener('DOMContentLoaded', async () => {
|
||||||
await restoreOptions();
|
await restoreOptions();
|
||||||
i18n.updateDocument();
|
i18n.updateDocument();
|
||||||
|
|
@ -358,6 +365,7 @@ select_openai_comp_model.addEventListener("change", warn_OpenAIComp_HostEmpty);
|
||||||
warn_ChatGPT_APIKeyEmpty();
|
warn_ChatGPT_APIKeyEmpty();
|
||||||
warn_Ollama_HostEmpty();
|
warn_Ollama_HostEmpty();
|
||||||
warn_OpenAIComp_HostEmpty();
|
warn_OpenAIComp_HostEmpty();
|
||||||
|
disable_MaxPromptLength();
|
||||||
|
|
||||||
const passwordField_chatgpt_api_key = document.getElementById('chatgpt_api_key');
|
const passwordField_chatgpt_api_key = document.getElementById('chatgpt_api_key');
|
||||||
const toggleIcon_chatgpt_api_key = document.getElementById('toggle_chatgpt_api_key');
|
const toggleIcon_chatgpt_api_key = document.getElementById('toggle_chatgpt_api_key');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue