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 -0Ignore whitespace
public/scripts/extensions/connection-manager/index.js+2 -0
@@ -40,6 +40,7 @@ const CC_COMMANDS = [
4040 'stop-strings',
4141 'start-reply-with',
4242 'reasoning-template',
43+ 'prompt-post-processing',
4344];
4445
4546const TC_COMMANDS = [
@@ -73,6 +74,7 @@ const FANCY_NAMES = {
7374 'stop-strings': 'Custom Stopping Strings',
7475 'start-reply-with': 'Start Reply With',
7576 'reasoning-template': 'Reasoning Template',
77+ 'prompt-post-processing': 'Prompt Post-Processing',
7678};
7779
7880/**
public/scripts/slash-commands.js+51 -0
@@ -33,6 +33,7 @@ import {
3333 removeMacros,
3434 renameCharacter,
3535 saveChatConditional,
36+ saveSettingsDebounced,
3637 sendMessageAsUser,
3738 sendSystemMessage,
3839 setActiveCharacter,
@@ -2363,6 +2364,56 @@ export function initDefaultSlashCommands() {
23632364 helpString: 'Copies the provided text to the OS clipboard. Returns an empty string.',
23642365 }));
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+
23662417 registerVariableCommands();
23672418}
23682419