Filter out inapplicable stop strings for Chat Completion (#5337) * Stop strings apply to Chat Completions and should not be greyed out. * Revert "Stop strings apply to Chat Completions and should not be greyed out." This reverts commit 51e5cfee41e1298b0005ff9df5d783c08820ed9a. * Stopping strings should only apply to Text Completions https://github.com/SillyTavern/SillyTavern/pull/5337#pullrequestreview-3987164461 * Custom stop strings still apply * Also apply to non-streaming message clean-up * This comment is now misplaced * Oops, wrong file * Revert package-lock change --------- Co-authored-by: user <user@exmaple.com> Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>

0e5928b13a2000c964eb64b1caf64969134ea0c1

DeclineThyself <235079501+DeclineThyself@users.noreply.github.com>

Signed
1 files changed, +9 -3Ignore whitespace
public/script.js+9 -3
@@ -2917,9 +2917,15 @@ export function substituteParams(content, options = {}) {
29172917 * Gets stopping sequences for the prompt.
29182918 * @param {boolean} isImpersonate A request is made to impersonate a user
29192919 * @param {boolean} isContinue A request is made to continue the message
2920+ * @param {string} [api] Optional API name to get API-specific stopping sequences for
29202921 * @returns {string[]} Array of stopping strings
29212922 */
29222923export function getStoppingStrings(isImpersonate, isContinue, api = main_api) {
2924+ // Only custom stop strings apply to Chat Completion
2925+ if (api === 'openai') {
2926+ return getCustomStoppingStrings();
2927+ }
2928+
29232929 const result = [];
29242930
29252931 if (power_user.context.names_as_stop_strings) {
@@ -3744,7 +3750,7 @@ class StreamingProcessor {
37443750 // when streaming, we cache the result of getStoppingStrings instead of calling it once per token.
37453751 const isImpersonate = this.type == 'impersonate';
37463752 const isContinue = this.type == 'continue';
37473753 this.stoppingStrings = getStoppingStrings(isImpersonate, isContinue, main_api);
37483754
37493755 try {
37503756 const sw = new Stopwatch(1000 / power_user.streaming_fps);
@@ -6317,7 +6323,7 @@ export function cleanUpMessage({ getMessage, isImpersonate, isContinue, displayI
63176323 // Allow for caching of stopping strings. getStoppingStrings is an expensive function, especially with macros
63186324 // enabled, so for streaming, we call it once and then pass it into each cleanUpMessage call.
63196325 if (!stoppingStrings) {
63206326 stoppingStrings = getStoppingStrings(isImpersonate, isContinue, main_api);
63216327 }
63226328
63236329 for (const stoppingString of stoppingStrings) {