mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Fix settings migration. Add lint rule.
This commit is contained in:
@ -60,6 +60,8 @@ module.exports = {
|
|||||||
'no-trailing-spaces': 'error',
|
'no-trailing-spaces': 'error',
|
||||||
'object-curly-spacing': ['error', 'always'],
|
'object-curly-spacing': ['error', 'always'],
|
||||||
'space-infix-ops': 'error',
|
'space-infix-ops': 'error',
|
||||||
|
'no-unused-expressions': ['error', { allowShortCircuit: true, allowTernary: true }],
|
||||||
|
'no-cond-assign': 'error',
|
||||||
|
|
||||||
// These rules should eventually be enabled.
|
// These rules should eventually be enabled.
|
||||||
'no-async-promise-executor': 'off',
|
'no-async-promise-executor': 'off',
|
||||||
|
@ -47,7 +47,7 @@ const EXPRESSION_API = {
|
|||||||
local: 0,
|
local: 0,
|
||||||
extras: 1,
|
extras: 1,
|
||||||
llm: 2,
|
llm: 2,
|
||||||
}
|
};
|
||||||
|
|
||||||
let expressionsList = null;
|
let expressionsList = null;
|
||||||
let lastCharacter = undefined;
|
let lastCharacter = undefined;
|
||||||
@ -979,25 +979,25 @@ function sampleClassifyText(text) {
|
|||||||
function onTextGenSettingsReady(args) {
|
function onTextGenSettingsReady(args) {
|
||||||
// Only call if inside an API call
|
// Only call if inside an API call
|
||||||
if (inApiCall) {
|
if (inApiCall) {
|
||||||
const emotions = DEFAULT_EXPRESSIONS.filter((e) => e != 'talkinghead')
|
const emotions = DEFAULT_EXPRESSIONS.filter((e) => e != 'talkinghead');
|
||||||
Object.assign(args, {
|
Object.assign(args, {
|
||||||
top_k: 1,
|
top_k: 1,
|
||||||
stop: [],
|
stop: [],
|
||||||
stopping_strings: [],
|
stopping_strings: [],
|
||||||
custom_token_bans: [],
|
custom_token_bans: [],
|
||||||
json_schema: {
|
json_schema: {
|
||||||
$schema: "http://json-schema.org/draft-04/schema#",
|
$schema: 'http://json-schema.org/draft-04/schema#',
|
||||||
type: "object",
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
emotion: {
|
emotion: {
|
||||||
type: "string",
|
type: 'string',
|
||||||
enum: emotions
|
enum: emotions,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
required: [
|
required: [
|
||||||
"emotion"
|
'emotion',
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1055,7 +1055,7 @@ async function getExpressionLabel(text) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toastr.info("Could not classify expression. Check the console or your backend for more information.")
|
toastr.info('Could not classify expression. Check the console or your backend for more information.');
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return getFallbackExpression();
|
return getFallbackExpression();
|
||||||
}
|
}
|
||||||
@ -1236,7 +1236,7 @@ async function getExpressionsList() {
|
|||||||
const data = await apiResult.json();
|
const data = await apiResult.json();
|
||||||
expressionsList = data.labels;
|
expressionsList = data.labels;
|
||||||
return expressionsList;
|
return expressionsList;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const apiResult = await fetch('/api/extra/classify/labels', {
|
const apiResult = await fetch('/api/extra/classify/labels', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
@ -1754,7 +1754,7 @@ async function fetchImagesNoCache() {
|
|||||||
function migrateSettings() {
|
function migrateSettings() {
|
||||||
if (Object.keys(extension_settings.expressions).includes('local')) {
|
if (Object.keys(extension_settings.expressions).includes('local')) {
|
||||||
if (extension_settings.expressions.local) {
|
if (extension_settings.expressions.local) {
|
||||||
extension_settings.expressions.api == EXPRESSION_API.local;
|
extension_settings.expressions.api = EXPRESSION_API.local;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete extension_settings.expressions.local;
|
delete extension_settings.expressions.local;
|
||||||
@ -1811,7 +1811,7 @@ function migrateSettings() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
await renderAdditionalExpressionSettings();
|
await renderAdditionalExpressionSettings();
|
||||||
$('#expression_api').val(extension_settings.expressions.api || 0);
|
$('#expression_api').val(extension_settings.expressions.api || EXPRESSION_API.extras);
|
||||||
|
|
||||||
$('#expression_custom_add').on('click', onClickExpressionAddCustom);
|
$('#expression_custom_add').on('click', onClickExpressionAddCustom);
|
||||||
$('#expression_custom_remove').on('click', onClickExpressionRemoveCustom);
|
$('#expression_custom_remove').on('click', onClickExpressionRemoveCustom);
|
||||||
|
Reference in New Issue
Block a user