diff --git a/.config/ags/modules/.configuration/default_options.jsonc b/.config/ags/modules/.configuration/default_options.jsonc index 61c01d2cd..80b2f6353 100644 --- a/.config/ags/modules/.configuration/default_options.jsonc +++ b/.config/ags/modules/.configuration/default_options.jsonc @@ -6,6 +6,7 @@ "defaultGPTProvider": "ollama_llama_3_2", "defaultTemperature": 0.5, "enhancements": true, + "charsEachUpdate": 50, // Lower = smoother update rate, but more update lag "keep_alive": -1, // For ollama. -1 means forever "useHistory": false, "safety": true, diff --git a/.config/ags/modules/.miscutils/md2pango.js b/.config/ags/modules/.miscutils/md2pango.js index 100699939..c49354659 100644 --- a/.config/ags/modules/.miscutils/md2pango.js +++ b/.config/ags/modules/.miscutils/md2pango.js @@ -49,8 +49,8 @@ const replaceCategory = (text, replaces) => { // Main function export function replaceInlineLatexWithCodeBlocks(text) { - return text.replace(/\\\[(.*?)\\\]|\\\((.*?)\\\)/gs, (match, square, round) => { - const latex = square || round; + return text.replace(/\\\[(.*?)\\\]|\\\((.*?)\\\)|\$\$(.*?)\$\$|(? { + const latex = square || round || double || single; return `\n\`\`\`latex\n${latex}\n\`\`\`\n`; }); } diff --git a/.config/ags/services/gemini.js b/.config/ags/services/gemini.js index 46fc9118c..5109b3650 100644 --- a/.config/ags/services/gemini.js +++ b/.config/ags/services/gemini.js @@ -62,6 +62,7 @@ class GeminiMessage extends Service { _role = ''; _parts = [{ text: '' }]; + _lastContentLength = 0; _thinking; _done = false; _rawData = ''; @@ -88,8 +89,11 @@ class GeminiMessage extends Service { } set content(content) { this._parts = [{ text: content }]; - this.notify('content') - this.emit('changed') + if (content.length - this._lastContentLength >= userOptions.ai.charsEachUpdate) { + this.notify('content') + this.emit('changed') + this._lastContentLength = content.length; + } } get parts() { return this._parts } diff --git a/.config/ags/services/gpt.js b/.config/ags/services/gpt.js index 3475f9548..717ee2932 100644 --- a/.config/ags/services/gpt.js +++ b/.config/ags/services/gpt.js @@ -91,6 +91,7 @@ class GPTMessage extends Service { _role = ''; _content = ''; + _lastContentLength = 0; _thinking; _done = false; @@ -111,8 +112,11 @@ class GPTMessage extends Service { get content() { return this._content } set content(content) { this._content = content; - this.notify('content') - this.emit('changed') + if (this._content.length - this._lastContentLength >= userOptions.ai.charsEachUpdate) { + this.notify('content') + this.emit('changed') + this._lastContentLength = this._content.length; + } } get label() { return this._parserState.parsed + this._parserState.stack.join('') }