Show the prompt id and name to the information in the AI API chat. See #436
This commit is contained in:
parent
bd2762b9d6
commit
9c0583af51
2 changed files with 21 additions and 8 deletions
|
|
@ -28,6 +28,8 @@ const urlParams = new URLSearchParams(window.location.search);
|
|||
const llm = urlParams.get('llm');
|
||||
const call_id = urlParams.get('call_id');
|
||||
const ph_def_val = urlParams.get('ph_def_val');
|
||||
const prompt_id = urlParams.get('prompt_id');
|
||||
const prompt_name = urlParams.get('prompt_name');
|
||||
|
||||
// Data received from the user
|
||||
let promptData = null;
|
||||
|
|
@ -85,6 +87,7 @@ switch (llm) {
|
|||
if(prefs_api.chatgpt_developer_messages && prefs_api.chatgpt_developer_messages.length > 0) {
|
||||
additional_text_elements.push({label: browser.i18n.getMessage("ChatGPT_Developer_Messages"), value: prefs_api.chatgpt_developer_messages});
|
||||
}
|
||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||
api_string: "ChatGPT API",
|
||||
model_string: prefs_api.chatgpt_model,
|
||||
|
|
@ -104,6 +107,7 @@ switch (llm) {
|
|||
if(prefs_api.google_gemini_system_instruction && prefs_api.google_gemini_system_instruction.length > 0) {
|
||||
additional_text_elements.push({label: browser.i18n.getMessage("GoogleGemini_SystemInstruction"), value: prefs_api.google_gemini_system_instruction});
|
||||
}
|
||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||
worker.postMessage({ type: 'init', google_gemini_api_key: prefs_api.google_gemini_api_key, google_gemini_model: prefs_api.google_gemini_model, google_gemini_system_instruction: prefs_api.google_gemini_system_instruction, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||
api_string: "Google Gemini API",
|
||||
|
|
@ -122,10 +126,13 @@ switch (llm) {
|
|||
messagesArea.setLLMName("Ollama Local");
|
||||
worker.postMessage({ type: 'init', ollama_host: prefs_api.ollama_host, ollama_model: prefs_api.ollama_model, ollama_num_ctx: prefs_api.ollama_num_ctx, ollama_think: prefs_api.ollama_think, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
|
||||
browser.runtime.sendMessage({command: "ollama_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
|
||||
let additional_text_elements = [];
|
||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||
api_string: "Ollama API",
|
||||
model_string: prefs_api.ollama_model,
|
||||
host_string: prefs_api.ollama_host
|
||||
host_string: prefs_api.ollama_host,
|
||||
additional_messages: additional_text_elements
|
||||
}), "info");
|
||||
break;
|
||||
}
|
||||
|
|
@ -137,10 +144,13 @@ switch (llm) {
|
|||
messageInput.setModel(prefs_api.openai_comp_model);
|
||||
messagesArea.setLLMName(prefs_api.openai_comp_chat_name);
|
||||
worker.postMessage({ type: 'init', openai_comp_host: prefs_api.openai_comp_host, openai_comp_model: prefs_api.openai_comp_model, openai_comp_api_key: prefs_api.openai_comp_api_key, openai_comp_use_v1: prefs_api.openai_comp_use_v1, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
|
||||
let additional_text_elements = [];
|
||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||
api_string: "OpenAI Compatible API",
|
||||
model_string: prefs_api.openai_comp_model,
|
||||
host_string: prefs_api.openai_comp_host
|
||||
host_string: prefs_api.openai_comp_host,
|
||||
additional_messages: additional_text_elements
|
||||
}), "info");
|
||||
browser.runtime.sendMessage({command: "openai_comp_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
|
||||
break;
|
||||
|
|
@ -153,10 +163,13 @@ switch (llm) {
|
|||
messageInput.setModel(prefs_api.anthropic_model);
|
||||
messagesArea.setLLMName("Anthropic");
|
||||
worker.postMessage({ type: 'init', anthropic_api_key: prefs_api.anthropic_api_key, anthropic_model: prefs_api.anthropic_model, anthropic_version: prefs_api.anthropic_version, anthropic_max_tokens: prefs_api.anthropic_max_tokens, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
|
||||
let additional_text_elements = [];
|
||||
additional_text_elements.push({label: "Prompt", value: '[' + prompt_id + '] ' + decodeURIComponent(prompt_name)});
|
||||
messagesArea.appendUserMessage(getAPIsInitMessageString({
|
||||
api_string: "Anthropic API",
|
||||
model_string: prefs_api.anthropic_model,
|
||||
version_string: prefs_api.anthropic_version
|
||||
version_string: prefs_api.anthropic_version,
|
||||
additional_messages: additional_text_elements
|
||||
}), "info");
|
||||
browser.runtime.sendMessage({command: "anthropic_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
browser.runtime.onMessage.addListener(listener2);
|
||||
|
||||
let win_options2 = {
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id2+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')),
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id5+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')+'&prompt_id='+encodeURIComponent(prompt_info.id) + '&prompt_name=' + encodeURIComponent(i18nConditionalGet(prompt_info.name))),
|
||||
type: "popup",
|
||||
}
|
||||
|
||||
|
|
@ -543,7 +543,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
browser.runtime.onMessage.addListener(listener5);
|
||||
|
||||
let win_options5 = {
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id5+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')),
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id5+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')+'&prompt_id='+encodeURIComponent(prompt_info.id) + '&prompt_name=' + encodeURIComponent(i18nConditionalGet(prompt_info.name))),
|
||||
type: "popup",
|
||||
}
|
||||
|
||||
|
|
@ -601,7 +601,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
browser.runtime.onMessage.addListener(listener3);
|
||||
|
||||
let win_options3 = {
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id3+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')),
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id5+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')+'&prompt_id='+encodeURIComponent(prompt_info.id) + '&prompt_name=' + encodeURIComponent(i18nConditionalGet(prompt_info.name))),
|
||||
type: "popup",
|
||||
}
|
||||
|
||||
|
|
@ -654,7 +654,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
browser.runtime.onMessage.addListener(listener4);
|
||||
|
||||
let win_options4 = {
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id4+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')),
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id5+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')+'&prompt_id='+encodeURIComponent(prompt_info.id) + '&prompt_name=' + encodeURIComponent(i18nConditionalGet(prompt_info.name))),
|
||||
type: "popup",
|
||||
}
|
||||
|
||||
|
|
@ -709,7 +709,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_
|
|||
browser.runtime.onMessage.addListener(listener5);
|
||||
|
||||
let win_options5 = {
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id5+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')),
|
||||
url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id5+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')+'&prompt_id='+encodeURIComponent(prompt_info.id) + '&prompt_name=' + encodeURIComponent(i18nConditionalGet(prompt_info.name))),
|
||||
type: "popup",
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue