forked from Shinonome/dots-hyprland
ai: fewer updates to fix one single latex expr being rendered 800 times
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
"defaultGPTProvider": "ollama_llama_3_2",
|
"defaultGPTProvider": "ollama_llama_3_2",
|
||||||
"defaultTemperature": 0.5,
|
"defaultTemperature": 0.5,
|
||||||
"enhancements": true,
|
"enhancements": true,
|
||||||
|
"charsEachUpdate": 50, // Lower = smoother update rate, but more update lag
|
||||||
"keep_alive": -1, // For ollama. -1 means forever
|
"keep_alive": -1, // For ollama. -1 means forever
|
||||||
"useHistory": false,
|
"useHistory": false,
|
||||||
"safety": true,
|
"safety": true,
|
||||||
|
|||||||
@@ -49,8 +49,8 @@ const replaceCategory = (text, replaces) => {
|
|||||||
// Main function
|
// Main function
|
||||||
|
|
||||||
export function replaceInlineLatexWithCodeBlocks(text) {
|
export function replaceInlineLatexWithCodeBlocks(text) {
|
||||||
return text.replace(/\\\[(.*?)\\\]|\\\((.*?)\\\)/gs, (match, square, round) => {
|
return text.replace(/\\\[(.*?)\\\]|\\\((.*?)\\\)|\$\$(.*?)\$\$|(?<!\w)\$(.*?[^\\])\$(?!\w)/gs, (match, square, round, double, single) => {
|
||||||
const latex = square || round;
|
const latex = square || round || double || single;
|
||||||
return `\n\`\`\`latex\n${latex}\n\`\`\`\n`;
|
return `\n\`\`\`latex\n${latex}\n\`\`\`\n`;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ class GeminiMessage extends Service {
|
|||||||
|
|
||||||
_role = '';
|
_role = '';
|
||||||
_parts = [{ text: '' }];
|
_parts = [{ text: '' }];
|
||||||
|
_lastContentLength = 0;
|
||||||
_thinking;
|
_thinking;
|
||||||
_done = false;
|
_done = false;
|
||||||
_rawData = '';
|
_rawData = '';
|
||||||
@@ -88,8 +89,11 @@ class GeminiMessage extends Service {
|
|||||||
}
|
}
|
||||||
set content(content) {
|
set content(content) {
|
||||||
this._parts = [{ text: content }];
|
this._parts = [{ text: content }];
|
||||||
this.notify('content')
|
if (content.length - this._lastContentLength >= userOptions.ai.charsEachUpdate) {
|
||||||
this.emit('changed')
|
this.notify('content')
|
||||||
|
this.emit('changed')
|
||||||
|
this._lastContentLength = content.length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get parts() { return this._parts }
|
get parts() { return this._parts }
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ class GPTMessage extends Service {
|
|||||||
|
|
||||||
_role = '';
|
_role = '';
|
||||||
_content = '';
|
_content = '';
|
||||||
|
_lastContentLength = 0;
|
||||||
_thinking;
|
_thinking;
|
||||||
_done = false;
|
_done = false;
|
||||||
|
|
||||||
@@ -111,8 +112,11 @@ class GPTMessage extends Service {
|
|||||||
get content() { return this._content }
|
get content() { return this._content }
|
||||||
set content(content) {
|
set content(content) {
|
||||||
this._content = content;
|
this._content = content;
|
||||||
this.notify('content')
|
if (this._content.length - this._lastContentLength >= userOptions.ai.charsEachUpdate) {
|
||||||
this.emit('changed')
|
this.notify('content')
|
||||||
|
this.emit('changed')
|
||||||
|
this._lastContentLength = this._content.length;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get label() { return this._parserState.parsed + this._parserState.stack.join('') }
|
get label() { return this._parserState.parsed + this._parserState.stack.join('') }
|
||||||
|
|||||||
Reference in New Issue
Block a user