Using a prompt from the compose window with a "Do reply" action is changed in "Substitute Text" [#353].
+
Using a prompt from the compose window with a "Do reply" action is changed in "Substitute Text", asking also to insert text if none is selected [#353].
Added an option when composing in plain text to remove the extra empty lines [#350].
+
[Ollama API] It's now possibile to define the default context length (the num_ctx parameter) in the options page [#351].
[ChatGPT Web] Updated the list of available models in the option page.
[ChatGPT Web] Opening the ChatGPT webpage from the options now enforce the selected model, if any.
[All APIs] Fix: Really correctly getting the message body even in multilevel subpart messages when processing incoming messages for tags or spam [#335].
diff --git a/_locales/en/messages.json b/_locales/en/messages.json
index b111175c..a2a5dec2 100644
--- a/_locales/en/messages.json
+++ b/_locales/en/messages.json
@@ -1279,4 +1279,16 @@
"message": "Check this option if you're composing the emails in plain text format.",
"description": ""
}
+ "Replace_No_Selected_Text": {
+ "message": "No text selected, would you like to insert the AI's response at the beginning of the email?",
+ "description": ""
+ },
+ "prefs_ollama_num_ctx": {
+ "message": "Number of context tokens",
+ "description": ""
+ },
+ "prefs_ollama_num_ctx_Info": {
+ "message": "The number of context tokens to use for the Ollama API. Set to 0 if you don't want to pass it as a parameter to the server.",
+ "description": ""
+ }
}
\ No newline at end of file
diff --git a/api_webchat/controller.js b/api_webchat/controller.js
index ec23e569..5e3e6b22 100644
--- a/api_webchat/controller.js
+++ b/api_webchat/controller.js
@@ -90,13 +90,13 @@ switch (llm) {
break;
}
case "ollama_api": {
- let prefs_api = await browser.storage.sync.get({ollama_host: '', ollama_model: '', do_debug: false});
+ let prefs_api = await browser.storage.sync.get({ollama_host: '', ollama_model: '', ollama_num_ctx: 0, do_debug: false});
let i18nStrings = {};
i18nStrings["ollama_api_request_failed"] = browser.i18n.getMessage('ollama_api_request_failed');
i18nStrings["error_connection_interrupted"] = browser.i18n.getMessage('error_connection_interrupted');
messageInput.setModel(prefs_api.ollama_model);
messagesArea.setLLMName("Ollama Local");
- worker.postMessage({ type: 'init', ollama_host: prefs_api.ollama_host, ollama_model: prefs_api.ollama_model, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
+ worker.postMessage({ type: 'init', ollama_host: prefs_api.ollama_host, ollama_model: prefs_api.ollama_model, ollama_num_ctx: prefs_api.ollama_num_ctx, do_debug: prefs_api.do_debug, i18nStrings: i18nStrings});
browser.runtime.sendMessage({command: "ollama_api_ready_" + call_id, window_id: (await browser.windows.getCurrent()).id});
messagesArea.appendUserMessage(browser.i18n.getMessage("ollama_api_connecting") + " \"" + prefs_api.ollama_host + "\" " +browser.i18n.getMessage("AndModel") + " \"" + prefs_api.ollama_model + "\"...", "info");
break;
diff --git a/js/api/ollama.js b/js/api/ollama.js
index 0f300243..c08fc2e5 100644
--- a/js/api/ollama.js
+++ b/js/api/ollama.js
@@ -21,11 +21,13 @@ export class Ollama {
host = '';
model = '';
stream = false;
+ num_ctx = 0;
- constructor(host, model, stream = false) {
+ constructor(host, model, stream = false, num_ctx = 0) {
this.host = host.trim().replace(/\/+$/, "");
this.model = model;
this.stream = stream;
+ this.num_ctx = num_ctx;
}
fetchModels = async () => {
@@ -78,6 +80,7 @@ export class Ollama {
model: this.model,
messages: messages,
stream: this.stream,
+ ...(this.num_ctx > 0 ? { num_ctx: parseInt(this.num_ctx) } : {})
}),
});
return response;
diff --git a/js/mzta-compose-script.js b/js/mzta-compose-script.js
index 13f93708..b0289e38 100644
--- a/js/mzta-compose-script.js
+++ b/js/mzta-compose-script.js
@@ -24,12 +24,19 @@ switch (message.command) {
case "replaceSelectedText": {
const selectedText = window.getSelection().toString();
+ let force_insert = false;
if (selectedText === '') {
- return Promise.resolve(false);
+ if(!confirm(browser.i18n.getMessage("Replace_No_Selected_Text"))) {
+ return Promise.resolve(false);
+ }else{
+ force_insert = true;
+ }
}
const sel = window.getSelection();
if (!sel || sel.type !== "Range" || !sel.rangeCount) {
- return Promise.resolve(false);
+ if(!force_insert) {
+ return Promise.resolve(false);
+ }
}
const r = sel.getRangeAt(0);
r.deleteContents();
diff --git a/js/workers/model-worker-ollama.js b/js/workers/model-worker-ollama.js
index 21396f5d..f29bab62 100644
--- a/js/workers/model-worker-ollama.js
+++ b/js/workers/model-worker-ollama.js
@@ -25,6 +25,7 @@ import { taLogger } from '../mzta-logger.js';
let ollama_host = null;
let ollama_model = '';
+let ollama_num_ctx = 0;
let ollama = null;
let stopStreaming = false;
let i18nStrings = null;
@@ -39,8 +40,9 @@ self.onmessage = async function(event) {
case 'init':
ollama_host = event.data.ollama_host;
ollama_model = event.data.ollama_model;
+ ollama_num_ctx = event.data.ollama_num_ctx;
//console.log(">>>>>>>>>>> ollama_host: " + ollama_host);
- ollama = new Ollama(ollama_host, ollama_model, true);
+ ollama = new Ollama(ollama_host, ollama_model, true, ollama_num_ctx);
do_debug = event.data.do_debug;
i18nStrings = event.data.i18nStrings;
taLog = new taLogger('model-worker-ollama', do_debug);
diff --git a/options/mzta-options-default.js b/options/mzta-options-default.js
index 62dda293..7db33787 100644
--- a/options/mzta-options-default.js
+++ b/options/mzta-options-default.js
@@ -31,6 +31,7 @@ export const prefs_default = {
chatgpt_developer_messages: '',
ollama_host: '',
ollama_model: '',
+ ollama_num_ctx: 0,
openai_comp_host: '', // For OpenAI Compatible API as LM-Studio
openai_comp_model: '',
openai_comp_api_key: '',
diff --git a/options/mzta-options.html b/options/mzta-options.html
index 7d49c0fe..2cb1636a 100644
--- a/options/mzta-options.html
+++ b/options/mzta-options.html
@@ -261,6 +261,17 @@