Merge branch 'staging' into tc-phi

8c42de756595900aca456f6cd9bfaba85391d024

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

3 files changed, +99 -17Ignore whitespace
public/scripts/slash-commands.js+94 -6
@@ -2079,8 +2079,9 @@ export function initDefaultSlashCommands() {
2079 name: 'replace',2079 name: 'replace',
2080 aliases: ['re'],2080 aliases: ['re'],
2081 callback: (async ({ mode = 'literal', pattern, replacer = '' }, text) => {2081 callback: (async ({ mode = 'literal', pattern, replacer = '' }, text) => {
2082 if (pattern === '')2082 if (!pattern) {
2083 throw new Error('Argument of \'pattern=\' cannot be empty');2083 throw new Error('Argument of \'pattern=\' cannot be empty');
2084 }
2084 switch (mode) {2085 switch (mode) {
2085 case 'literal':2086 case 'literal':
2086 return text.replaceAll(pattern, replacer);2087 return text.replaceAll(pattern, replacer);
@@ -2123,11 +2124,98 @@ export function initDefaultSlashCommands() {
2123 </div>2124 </div>
2124 <div>2125 <div>
2125 <strong>Example:</strong>2126 <strong>Example:</strong>
2126 <pre>/let x Blue house and blue car || </pre>2127 <pre><code class="language-stscript">/let x Blue house and blue car || </code></pre>
2127 <pre>/replace pattern="blue" {{var::x}} | /echo |/# Blue house and car ||</pre>2128 <pre><code class="language-stscript">/replace pattern="blue" {{var::x}} | /echo |/# Blue house and car ||</code></pre>
2128 <pre>/replace pattern="blue" replacer="red" {{var::x}} | /echo |/# Blue house and red car ||</pre>2129 <pre><code class="language-stscript">/replace pattern="blue" replacer="red" {{var::x}} | /echo |/# Blue house and red car ||</code></pre>
2129 <pre>/replace mode=regex pattern="/blue/i" replacer="red" {{var::x}} | /echo |/# red house and blue car ||</pre>2130 <pre><code class="language-stscript">/replace mode=regex pattern="/blue/i" replacer="red" {{var::x}} | /echo |/# red house and blue car ||</code></pre>
2130 <pre>/replace mode=regex pattern="/blue/gi" replacer="red" {{var::x}} | /echo |/# red house and red car ||</pre>2131 <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>
2131 </div>2219 </div>
2132 `,2220 `,
2133 }));2221 }));
public/scripts/textgen-models.js+4 -10
@@ -41,12 +41,7 @@ const OPENROUTER_PROVIDERS = [
41 'Avian',41 'Avian',
42 'Lambda',42 'Lambda',
43 'Azure',43 'Azure',
44 'Modal',
45 'AnyScale',
46 'Replicate',
47 'Perplexity',44 'Perplexity',
48 'Recursal',
49 'OctoAI',
50 'DeepSeek',45 'DeepSeek',
51 'Infermatic',46 'Infermatic',
52 'AI21',47 'AI21',
@@ -54,10 +49,10 @@ const OPENROUTER_PROVIDERS = [
54 'Inflection',49 'Inflection',
55 'xAI',50 'xAI',
56 'Cloudflare',51 'Cloudflare',
57 'SF Compute',
58 'Minimax',52 'Minimax',
59 'Nineteen',53 'Nineteen',
60 'Liquid',54 'Liquid',
55 'GMICloud',
61 'Stealth',56 'Stealth',
62 'NCompass',57 'NCompass',
63 'InferenceNet',58 'InferenceNet',
@@ -74,14 +69,13 @@ const OPENROUTER_PROVIDERS = [
74 'Phala',69 'Phala',
75 'Cent-ML',70 'Cent-ML',
76 'Venice',71 'Venice',
77 '01.AI',72 'OpenInference',
78 'HuggingFace',73 'Atoma',
74 'Enfer',
79 'Mancer',75 'Mancer',
80 'Mancer 2',76 'Mancer 2',
81 'Hyperbolic',77 'Hyperbolic',
82 'Hyperbolic 2',78 'Hyperbolic 2',
83 'Lynn 2',
84 'Lynn',
85 'Reflection',79 'Reflection',
86];80];
8781
public/scripts/textgen-settings.js+1 -1
@@ -1146,7 +1146,7 @@ function tryParseStreamingError(response, decoded) {
1146 // No JSON. Do nothing.1146 // No JSON. Do nothing.
1147 }1147 }
11481148
1149 const message = data?.error?.message || data?.message || data?.detail;1149 const message = data?.error?.message || data?.error || data?.message || data?.detail;
11501150
1151 if (message) {1151 if (message) {
1152 toastr.error(message, 'Text Completion API');1152 toastr.error(message, 'Text Completion API');