PPP command and connection profiles (#4079) * Add PPP command * Add PPP to connection profiles

4c3bb1aede8b3aaae497607242bf04284d647330

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

Signed
2 files changed, +53 -0Showing whitespace changes
public/scripts/extensions/connection-manager/index.js+2 -0
@@ -40,6 +40,7 @@ const CC_COMMANDS = [
40 'stop-strings',40 'stop-strings',
41 'start-reply-with',41 'start-reply-with',
42 'reasoning-template',42 'reasoning-template',
43 'prompt-post-processing',
43];44];
4445
45const TC_COMMANDS = [46const TC_COMMANDS = [
@@ -73,6 +74,7 @@ const FANCY_NAMES = {
73 'stop-strings': 'Custom Stopping Strings',74 'stop-strings': 'Custom Stopping Strings',
74 'start-reply-with': 'Start Reply With',75 'start-reply-with': 'Start Reply With',
75 'reasoning-template': 'Reasoning Template',76 'reasoning-template': 'Reasoning Template',
77 'prompt-post-processing': 'Prompt Post-Processing',
76};78};
7779
78/**80/**
public/scripts/slash-commands.js+51 -0
@@ -33,6 +33,7 @@ import {
33 removeMacros,33 removeMacros,
34 renameCharacter,34 renameCharacter,
35 saveChatConditional,35 saveChatConditional,
36 saveSettingsDebounced,
36 sendMessageAsUser,37 sendMessageAsUser,
37 sendSystemMessage,38 sendSystemMessage,
38 setActiveCharacter,39 setActiveCharacter,
@@ -2363,6 +2364,56 @@ export function initDefaultSlashCommands() {
2363 helpString: 'Copies the provided text to the OS clipboard. Returns an empty string.',2364 helpString: 'Copies the provided text to the OS clipboard. Returns an empty string.',
2364 }));2365 }));
23652366
2367
2368 const promptPostProcessingEnumProvider = () => Array
2369 .from(document.getElementById('custom_prompt_post_processing').querySelectorAll('option'))
2370 .map(option => new SlashCommandEnumValue(option.value || 'none', option.textContent, enumTypes.enum));
2371 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
2372 name: 'prompt-post-processing',
2373 aliases: ['ppp'],
2374 helpString: `
2375 <div>
2376 Sets a "Prompt Post-Processing" type. Gets the current selection if no value is provided.
2377 </div>
2378 <div>
2379 <strong>Examples:</strong>
2380 </div>
2381 <ul>
2382 <li><pre><code class="language-stscript">/prompt-post-processing | /echo</code></pre></li>
2383 <li><pre><code class="language-stscript">/prompt-post-processing single</code></pre></li>
2384 </ul>
2385 `,
2386 namedArgumentList: [],
2387 unnamedArgumentList: [
2388 SlashCommandArgument.fromProps({
2389 description: 'value',
2390 typeList: [ARGUMENT_TYPE.STRING],
2391 acceptsMultiple: false,
2392 isRequired: true,
2393 forceEnum: true,
2394 enumProvider: promptPostProcessingEnumProvider,
2395 }),
2396 ],
2397 callback: (_args, value) => {
2398 const stringValue = String(value ?? '').trim().toLowerCase();
2399 if (!stringValue) {
2400 return oai_settings.custom_prompt_post_processing || 'none';
2401 }
2402
2403 const validValues = promptPostProcessingEnumProvider().map(option => option.value);
2404 if (!validValues.includes(stringValue)) {
2405 throw new Error(`Invalid value "${stringValue}". Valid values are: ${validValues.join(', ')}`);
2406 }
2407
2408 // 'none' value must be coerced to an empty string
2409 oai_settings.custom_prompt_post_processing = stringValue === 'none' ? '' : stringValue;
2410 $('#custom_prompt_post_processing').val(oai_settings.custom_prompt_post_processing);
2411 saveSettingsDebounced();
2412
2413 return oai_settings.custom_prompt_post_processing;
2414 },
2415 }));
2416
2366 registerVariableCommands();2417 registerVariableCommands();
2367}2418}
23682419