Merge branch 'staging' into tc-phi

8c42de756595900aca456f6cd9bfaba85391d024

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +99 -17Showing whitespace changes
public/scripts/slash-commands.js+94 -6
@@ -2079,8 +2079,9 @@ export function initDefaultSlashCommands() {
20792079 name: 'replace',
20802080 aliases: ['re'],
20812081 callback: (async ({ mode = 'literal', pattern, replacer = '' }, text) => {
20822082 if (!pattern === '') {
20832083 throw new Error('Argument of \'pattern=\' cannot be empty');
2084+ }
20842085 switch (mode) {
20852086 case 'literal':
20862087 return text.replaceAll(pattern, replacer);
@@ -2123,11 +2124,98 @@ export function initDefaultSlashCommands() {
21232124 </div>
21242125 <div>
21252126 <strong>Example:</strong>
21262127 <pre><code class="language-stscript">/let x Blue house and blue car || </code></pre>
21272128 <pre><code class="language-stscript">/replace pattern="blue" {{var::x}} | /echo |/# Blue house and car ||</code></pre>
21282129 <pre><code class="language-stscript">/replace pattern="blue" replacer="red" {{var::x}} | /echo |/# Blue house and red car ||</code></pre>
21292130 <pre><code class="language-stscript">/replace mode=regex pattern="/blue/i" replacer="red" {{var::x}} | /echo |/# red house and blue car ||</code></pre>
21302131 <pre><code class="language-stscript">/replace mode=regex pattern="/blue/gi" replacer="red" {{var::x}} | /echo |/# red house and red car ||</code></pre>
2132+ </div>
2133+ `,
2134+ }));
2135+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
2136+ name: 'test',
2137+ callback: (({ pattern }, text) => {
2138+ if (!pattern) {
2139+ throw new Error('Argument of \'pattern=\' cannot be empty');
2140+ }
2141+ const re = regexFromString(pattern.toString());
2142+ if (!re) {
2143+ throw new Error('The value of \'pattern\' argument is not a valid regular expression.');
2144+ }
2145+ return JSON.stringify(re.test(text.toString()));
2146+ }),
2147+ returns: 'true | false',
2148+ namedArgumentList: [
2149+ new SlashCommandNamedArgument(
2150+ 'pattern', 'pattern to find', [ARGUMENT_TYPE.STRING], true, false,
2151+ ),
2152+ ],
2153+ unnamedArgumentList: [
2154+ new SlashCommandArgument(
2155+ 'text to test', [ARGUMENT_TYPE.STRING], true, false,
2156+ ),
2157+ ],
2158+ helpString: `
2159+ <div>
2160+ Tests text for a regular expression match.
2161+ </div>
2162+ <div>
2163+ Returns <code>true</code> if the match is found, <code>false</code> otherwise.
2164+ </div>
2165+ <div>
2166+ <strong>Example:</strong>
2167+ <pre><code class="language-stscript">/let x Blue house and green car ||</code></pre>
2168+ <pre><code class="language-stscript">/test pattern="green" {{var::x}} | /echo |/# true ||</code></pre>
2169+ <pre><code class="language-stscript">/test pattern="blue" {{var::x}} | /echo |/# false ||</code></pre>
2170+ <pre><code class="language-stscript">/test pattern="/blue/i" {{var::x}} | /echo |/# true ||</code></pre>
2171+ </div>
2172+ `,
2173+ }));
2174+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
2175+ name: 'match',
2176+ callback: (({ pattern }, text) => {
2177+ if (!pattern) {
2178+ throw new Error('Argument of \'pattern=\' cannot be empty');
2179+ }
2180+ const re = regexFromString(pattern.toString());
2181+ if (!re) {
2182+ throw new Error('The value of \'pattern\' argument is not a valid regular expression.');
2183+ }
2184+ if (re.flags.includes('g')) {
2185+ return JSON.stringify([...text.toString().matchAll(re)]);
2186+ } else {
2187+ const match = text.toString().match(re);
2188+ return match ? JSON.stringify(match) : '';
2189+ }
2190+ }),
2191+ returns: 'group array for each match',
2192+ namedArgumentList: [
2193+ new SlashCommandNamedArgument(
2194+ 'pattern', 'pattern to find', [ARGUMENT_TYPE.STRING], true, false,
2195+ ),
2196+ ],
2197+ unnamedArgumentList: [
2198+ new SlashCommandArgument(
2199+ 'text to match against', [ARGUMENT_TYPE.STRING], true, false,
2200+ ),
2201+ ],
2202+ helpString: `
2203+ <div>
2204+ Retrieves regular expression matches in the given text
2205+ </div>
2206+ <div>
2207+ Returns an array of groups (with the first group being the full match). If the regex contains the global flag (i.e. <code>/g</code>),
2208+ multiple nested arrays are returned for each match. If the regex is global, returns <code>[]</code> if no matches are found,
2209+ otherwise it returns an empty string.
2210+ </div>
2211+ <div>
2212+ <strong>Example:</strong>
2213+ <pre><code class="language-stscript">/let x color_green green lamp color_blue ||</code></pre>
2214+ <pre><code class="language-stscript">/match pattern="green" {{var::x}} | /echo |/# [ "green" ] ||</code></pre>
2215+ <pre><code class="language-stscript">/match pattern="color_(\\w+)" {{var::x}} | /echo |/# [ "color_green", "green" ] ||</code></pre>
2216+ <pre><code class="language-stscript">/match pattern="/color_(\\w+)/g" {{var::x}} | /echo |/# [ [ "color_green", "green" ], [ "color_blue", "blue" ] ] ||</code></pre>
2217+ <pre><code class="language-stscript">/match pattern="orange" {{var::x}} | /echo |/# ||</code></pre>
2218+ <pre><code class="language-stscript">/match pattern="/orange/g" {{var::x}} | /echo |/# [] ||</code></pre>
21312219 </div>
21322220 `,
21332221 }));
public/scripts/textgen-models.js+4 -10
@@ -41,12 +41,7 @@ const OPENROUTER_PROVIDERS = [
4141 'Avian',
4242 'Lambda',
4343 'Azure',
44- 'Modal',
45- 'AnyScale',
46- 'Replicate',
4744 'Perplexity',
48- 'Recursal',
49- 'OctoAI',
5045 'DeepSeek',
5146 'Infermatic',
5247 'AI21',
@@ -54,10 +49,10 @@ const OPENROUTER_PROVIDERS = [
5449 'Inflection',
5550 'xAI',
5651 'Cloudflare',
57- 'SF Compute',
5852 'Minimax',
5953 'Nineteen',
6054 'Liquid',
55+ 'GMICloud',
6156 'Stealth',
6257 'NCompass',
6358 'InferenceNet',
@@ -74,14 +69,13 @@ const OPENROUTER_PROVIDERS = [
7469 'Phala',
7570 'Cent-ML',
7671 'Venice',
7772 '01.AIOpenInference',
7873 'HuggingFaceAtoma',
74+ 'Enfer',
7975 'Mancer',
8076 'Mancer 2',
8177 'Hyperbolic',
8278 'Hyperbolic 2',
83- 'Lynn 2',
84- 'Lynn',
8579 'Reflection',
8680];
8781
public/scripts/textgen-settings.js+1 -1
@@ -1146,7 +1146,7 @@ function tryParseStreamingError(response, decoded) {
11461146 // No JSON. Do nothing.
11471147 }
11481148
11491149 const message = data?.error?.message || data?.error || data?.message || data?.detail;
11501150
11511151 if (message) {
11521152 toastr.error(message, 'Text Completion API');