Merge branch 'staging' into timed-wi

This commit is contained in:
Cohee
2024-06-23 20:24:53 +03:00
5 changed files with 32 additions and 12 deletions

View File

@@ -2877,11 +2877,12 @@
</div> </div>
<h4 data-i18n="Enter a Model ID">Enter a Model ID</h4> <h4 data-i18n="Enter a Model ID">Enter a Model ID</h4>
<div class="flex-container"> <div class="flex-container">
<input id="custom_model_id" class="text_pole wide100p" maxlength="500" value="" autocomplete="off" data-i18n="[placeholder]Example: gpt-3.5-turbo" placeholder="Example: gpt-3.5-turbo"> <input list="model_custom_select_fill" id="custom_model_id" class="text_pole wide100p" maxlength="500" value="" autocomplete="off" data-i18n="[placeholder]Example: gpt-3.5-turbo" placeholder="Example: gpt-3.5-turbo">
<datalist id="model_custom_select_fill" class="text_pole model_custom_select"></datalist>
</div> </div>
<h4 data-i18n="Available Models">Available Models</h4> <h4 data-i18n="Available Models">Available Models</h4>
<div class="flex-container"> <div class="flex-container">
<select id="model_custom_select" class="text_pole"></select> <select id="model_custom_select" class="text_pole model_custom_select"></select>
</div> </div>
<h4 data-i18n="Prompt Post-Processing">Prompt Post-Processing</h4> <h4 data-i18n="Prompt Post-Processing">Prompt Post-Processing</h4>
<select id="custom_prompt_post_processing" class="text_pole" title="Applies additional processing to the prompt before sending it to the API." data-i18n="[title]Applies additional processing to the prompt before sending it to the API."> <select id="custom_prompt_post_processing" class="text_pole" title="Applies additional processing to the prompt before sending it to the API." data-i18n="[title]Applies additional processing to the prompt before sending it to the API.">

View File

@@ -1551,10 +1551,10 @@ function saveModelList(data) {
} }
if (oai_settings.chat_completion_source == chat_completion_sources.CUSTOM) { if (oai_settings.chat_completion_source == chat_completion_sources.CUSTOM) {
$('#model_custom_select').empty(); $('.model_custom_select').empty();
$('#model_custom_select').append('<option value="">None</option>'); $('.model_custom_select').append('<option value="">None</option>');
model_list.forEach((model) => { model_list.forEach((model) => {
$('#model_custom_select').append( $('.model_custom_select').append(
$('<option>', { $('<option>', {
value: model.id, value: model.id,
text: model.id, text: model.id,
@@ -3164,7 +3164,7 @@ async function getStatusOpen() {
} }
if (oai_settings.chat_completion_source === chat_completion_sources.CUSTOM) { if (oai_settings.chat_completion_source === chat_completion_sources.CUSTOM) {
$('#model_custom_select').empty(); $('.model_custom_select').empty();
data.custom_url = oai_settings.custom_url; data.custom_url = oai_settings.custom_url;
data.custom_include_headers = oai_settings.custom_include_headers; data.custom_include_headers = oai_settings.custom_include_headers;
} }

View File

@@ -73,7 +73,7 @@ export class SlashCommandArgument {
this.forceEnum = forceEnum; this.forceEnum = forceEnum;
// If no enums were set explictly and the type is one where we know possible enum values, we set them here // If no enums were set explictly and the type is one where we know possible enum values, we set them here
if (!this.enumList.length && this.typeList.includes(ARGUMENT_TYPE.BOOLEAN)) this.enumList = commonEnumProviders.boolean()(); if (!this.enumList.length && this.typeList.length === 1 && this.typeList.includes(ARGUMENT_TYPE.BOOLEAN)) this.enumList = commonEnumProviders.boolean()();
} }
} }

View File

@@ -623,6 +623,25 @@ export function isFalseBoolean(arg) {
return ['off', 'false', '0'].includes(arg?.trim()?.toLowerCase()); return ['off', 'false', '0'].includes(arg?.trim()?.toLowerCase());
} }
/**
* Parses an array either as a comma-separated string or as a JSON array.
* @param {string} value String to parse
* @returns {string[]} The parsed array.
*/
export function parseStringArray(value) {
if (!value || typeof value !== 'string') return [];
try {
const parsedValue = JSON.parse(value);
if (!Array.isArray(parsedValue)) {
throw new Error('Not an array');
}
return parsedValue.map(x => String(x));
} catch (e) {
return value.split(',').map(x => x.trim()).filter(x => x);
}
}
/** /**
* Checks if a number is odd. * Checks if a number is odd.
* @param {number} number The number to check. * @param {number} number The number to check.
@@ -1539,8 +1558,8 @@ export function flashHighlight(element, timespan = 2000) {
* @returns {boolean} Whether the control has an animation applied * @returns {boolean} Whether the control has an animation applied
*/ */
export function hasAnimation(control) { export function hasAnimation(control) {
const animatioName = getComputedStyle(control, null)["animation-name"]; const animatioName = getComputedStyle(control, null)['animation-name'];
return animatioName != "none"; return animatioName != 'none';
} }
/** /**

View File

@@ -1,5 +1,5 @@
import { saveSettings, callPopup, substituteParams, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types, getExtensionPromptByName, saveMetadata, getCurrentChatId, extension_prompt_roles } from '../script.js'; import { saveSettings, callPopup, substituteParams, getRequestHeaders, chat_metadata, this_chid, characters, saveCharacterDebounced, menu_type, eventSource, event_types, getExtensionPromptByName, saveMetadata, getCurrentChatId, extension_prompt_roles } from '../script.js';
import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, getSortableDelay, escapeRegex, PAGINATION_TEMPLATE, navigation_option, waitUntilCondition, isTrueBoolean, setValueByPath, flashHighlight, select2ModifyOptions, getSelect2OptionId, dynamicSelect2DataViaAjax, highlightRegex, select2ChoiceClickSubscribe, isFalseBoolean, getSanitizedFilename, checkOverwriteExistingData, getStringHash } from './utils.js'; import { download, debounce, initScrollHeight, resetScrollHeight, parseJsonFile, extractDataFromPng, getFileBuffer, getCharaFilename, getSortableDelay, escapeRegex, PAGINATION_TEMPLATE, navigation_option, waitUntilCondition, isTrueBoolean, setValueByPath, flashHighlight, select2ModifyOptions, getSelect2OptionId, dynamicSelect2DataViaAjax, highlightRegex, select2ChoiceClickSubscribe, isFalseBoolean, getSanitizedFilename, checkOverwriteExistingData, getStringHash, parseStringArray } from './utils.js';
import { extension_settings, getContext } from './extensions.js'; import { extension_settings, getContext } from './extensions.js';
import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from './authors-note.js'; import { NOTE_MODULE_NAME, metadata_keys, shouldWIAddPrompt } from './authors-note.js';
import { isMobile } from './RossAscends-mods.js'; import { isMobile } from './RossAscends-mods.js';
@@ -883,7 +883,7 @@ function registerWorldInfoSlashCommands() {
} }
if (Array.isArray(fieldValue)) { if (Array.isArray(fieldValue)) {
return fieldValue.map(x => substituteParams(x)).join(', '); return JSON.stringify(fieldValue.map(x => substituteParams(x)));
} }
return substituteParams(String(fieldValue)); return substituteParams(String(fieldValue));
@@ -950,7 +950,7 @@ function registerWorldInfoSlashCommands() {
} }
if (Array.isArray(entry[field])) { if (Array.isArray(entry[field])) {
entry[field] = value.split(',').map(x => x.trim()).filter(x => x); entry[field] = parseStringArray(value);
} else if (typeof entry[field] === 'boolean') { } else if (typeof entry[field] === 'boolean') {
entry[field] = isTrueBoolean(value); entry[field] = isTrueBoolean(value);
} else if (typeof entry[field] === 'number') { } else if (typeof entry[field] === 'number') {