mirror of
https://github.com/Wx-2025/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 04:35:51 +00:00
release: v2.2.3 [2026-05-27 23:06:48]
### 新功能 - Function Call 填表开关下方新增公益站风险提示横幅:部分公益站会屏蔽 tools 参数,请确认支持情况避免被意外封禁 ### 修复 - **Function Call 填表**: - 修复 ST 代理以 HTTP 200 + error body 形式返回错误、导致降级重试机制从未触发的问题 - 修复思考模式模型(如 DeepSeek v4-flash)因 tool_choice 不兼容返回 Bad Request 后正确降级并重试 - 重试时自动追加强制调用指令,防止思考模型绕过工具直接输出文本造成无效二次开销 - **超级记忆 / 翰林院**: - 修复 `getRagSettings()` 读写顶层路径而非嵌套路径,导致打开超级记忆面板后向量化、归档等开关在重载时被全默认值覆盖的问题 - 修复自动归档失效问题 - 修复归档管理器在同一事件中被三次触发的回归问题 - 修复翰林院设置旧版迁移逻辑异常
This commit is contained in:
@@ -36,47 +36,12 @@
|
||||
<!-- API Settings Tab -->
|
||||
<div id="sinan-api-settings-tab" class="sinan-tab-pane active">
|
||||
<fieldset class="settings-group">
|
||||
<legend>Jqyh API</legend>
|
||||
<div class="control-block-with-switch">
|
||||
<label for="amily2_jqyh_enabled"><strong>启用 Jqyh API</strong></label>
|
||||
<label class="toggle-switch">
|
||||
<input id="amily2_jqyh_enabled" type="checkbox" />
|
||||
<span class="slider"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div id="amily2_jqyh_content" style="display: none;" class="inline-settings-grid">
|
||||
<label for="amily2_jqyh_api_mode">API 模式</label>
|
||||
<select id="amily2_jqyh_api_mode" class="text_pole">
|
||||
<option value="openai_test">全兼容模式</option>
|
||||
<option value="sillytavern_preset">SillyTavern 预设</option>
|
||||
</select>
|
||||
|
||||
<div id="amily2_jqyh_compatible_config" class="inline-settings-grid" style="grid-column: 1 / -1;">
|
||||
<label for="amily2_jqyh_api_url">API URL</label>
|
||||
<input type="text" id="amily2_jqyh_api_url" class="text_pole" placeholder="例如: https://api.openai.com/v1">
|
||||
<label for="amily2_jqyh_api_key">API Key</label>
|
||||
<input type="password" id="amily2_jqyh_api_key" class="text_pole" placeholder="请输入您的 API Key">
|
||||
<label for="amily2_jqyh_model">模型</label>
|
||||
<div class="amily2_opt_preset_selector_wrapper">
|
||||
<input type="text" id="amily2_jqyh_model" class="text_pole" placeholder="请先获取模型列表或手动输入">
|
||||
<select id="amily2_jqyh_model_select" class="text_pole" style="display: none;"></select>
|
||||
</div>
|
||||
<div class="jqyh-button-row" style="grid-column: 1 / -1;">
|
||||
<button id="amily2_jqyh_fetch_models" class="menu_button secondary" title="获取模型列表"><i class="fas fa-sync-alt"></i> 获取模型</button>
|
||||
<button id="amily2_jqyh_test_connection" class="menu_button primary"><i class="fas fa-plug"></i> 测试连接</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="amily2_jqyh_preset_config" class="inline-settings-grid" style="display: none; grid-column: 1 / -1;">
|
||||
<label for="amily2_jqyh_tavern_profile">选择酒馆预设</label>
|
||||
<select id="amily2_jqyh_tavern_profile" class="text_pole"></select>
|
||||
</div>
|
||||
|
||||
<label for="amily2_jqyh_max_tokens">最大 Tokens: <span id="amily2_jqyh_max_tokens_value">4000</span></label>
|
||||
<input type="number" class="text_pole" id="amily2_jqyh_max_tokens" min="100" max="100000" value="4000">
|
||||
<label for="amily2_jqyh_temperature">温度: <span id="amily2_jqyh_temperature_value">0.7</span></label>
|
||||
<input type="number" class="text_pole" id="amily2_jqyh_temperature" min="0" max="2" value="0.7">
|
||||
</div>
|
||||
<legend>剧情优化 API</legend>
|
||||
<p class="notes" style="margin: 0;">
|
||||
剧情优化所用的连接配置统一在
|
||||
<strong>API 连接配置 → 功能分配 → 剧情优化 / JQYH</strong>
|
||||
中指定,无需在此单独填写。
|
||||
</p>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="settings-group">
|
||||
|
||||
@@ -485,8 +485,7 @@ export async function getApiSettings(slot = 'main') {
|
||||
apiProvider: apiMode,
|
||||
apiUrl: settings.plotOpt_apiUrl?.trim() || '',
|
||||
apiKey: configManager.get('plotOpt_apiKey') || '',
|
||||
model: document.getElementById('amily2_opt_model')?.value?.trim()
|
||||
|| settings.plotOpt_model || '',
|
||||
model: settings.plotOpt_model || '',
|
||||
maxTokens: settings.plotOpt_max_tokens ?? 65500,
|
||||
temperature: settings.plotOpt_temperature ?? 1.0,
|
||||
tavernProfile: '',
|
||||
|
||||
@@ -15,7 +15,6 @@ import { resolveHistoriographyRuleConfig } from "../utils/config/RuleProfileMana
|
||||
|
||||
import { getPresetPrompts, getMixedOrder } from '../PresetSettings/index.js';
|
||||
import { callAI, generateRandomSeed } from './api.js';
|
||||
import { callJqyhAI } from './api/JqyhApi.js';
|
||||
import { callConcurrentAI } from './api/ConcurrentApi.js';
|
||||
|
||||
export async function processOptimization(latestMessage, previousMessages) {
|
||||
@@ -480,7 +479,7 @@ export async function processPlotOptimization(currentUserMessage, contextMessage
|
||||
onProgress(getRandomText(['正在检索辅助记忆 (LLM-B)...', '正在扫描平行世界线 (LLM-B)...']), false);
|
||||
|
||||
onProgress(getRandomText(['正在与核心意识同步 (LLM-A)...', '正在等待灵魂共鸣 (LLM-A)...']), false);
|
||||
const promise1 = (settings.jqyhEnabled ? callJqyhAI(mainMessages) : callAI(mainMessages, { slot: 'plotOpt' })).then(res => {
|
||||
const promise1 = callAI(mainMessages, { slot: 'plotOpt' }).then(res => {
|
||||
onProgress(getRandomText(['正在与核心意识同步 (LLM-A)...', '正在等待灵魂共鸣 (LLM-A)...']), true);
|
||||
return res;
|
||||
});
|
||||
@@ -554,7 +553,7 @@ export async function processPlotOptimization(currentUserMessage, contextMessage
|
||||
attempt++;
|
||||
console.log(`[${extensionName}] 剧情优化第 ${attempt} 次尝试...`);
|
||||
|
||||
const rawResponse = settings.jqyhEnabled ? await callJqyhAI(mainMessages) : await callAI(mainMessages, { slot: 'plotOpt' });
|
||||
const rawResponse = await callAI(mainMessages, { slot: 'plotOpt' });
|
||||
|
||||
if (cancellationState.isCancelled) {
|
||||
console.log(`[${extensionName}] 优化任务在API调用后被中止。`);
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
import { extension_settings, getContext } from "/scripts/extensions.js";
|
||||
import { characters, this_chid, getRequestHeaders, saveSettingsDebounced, eventSource, event_types } from "/script.js";
|
||||
import { defaultSettings, extensionName } from "../utils/settings.js";
|
||||
import { testJqyhApiConnection, fetchJqyhModels } from '../core/api/JqyhApi.js';
|
||||
import { testConcurrentApiConnection, fetchConcurrentModels } from '../core/api/ConcurrentApi.js';
|
||||
import { safeLorebooks, safeCharLorebooks, safeLorebookEntries } from "../core/tavernhelper-compatibility.js";
|
||||
import { createDrawer } from '../ui/drawer.js';
|
||||
@@ -45,30 +44,6 @@ function opt_toCamelCase(str) {
|
||||
return str.replace(/[-_]([a-z])/g, (g) => g[1].toUpperCase());
|
||||
}
|
||||
|
||||
function opt_updateApiUrlVisibility(panel, apiMode) {
|
||||
const customApiSettings = panel.find('#amily2_opt_custom_api_settings_block');
|
||||
const tavernProfileSettings = panel.find('#amily2_opt_tavern_api_profile_block');
|
||||
const apiUrlInput = panel.find('#amily2_opt_api_url');
|
||||
|
||||
customApiSettings.hide();
|
||||
tavernProfileSettings.hide();
|
||||
|
||||
if (apiMode === 'tavern') {
|
||||
tavernProfileSettings.show();
|
||||
} else {
|
||||
customApiSettings.show();
|
||||
if (apiMode === 'google') {
|
||||
panel.find('#amily2_opt_api_url_block').hide();
|
||||
const googleUrl = 'https://generativelanguage.googleapis.com';
|
||||
if (apiUrlInput.val() !== googleUrl) {
|
||||
apiUrlInput.val(googleUrl).attr('type', 'text').trigger('change');
|
||||
}
|
||||
} else {
|
||||
panel.find('#amily2_opt_api_url_block').show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function opt_updateWorldbookSourceVisibility(panel, source) {
|
||||
const manualSelectionWrapper = panel.find('#amily2_opt_worldbook_select_wrapper');
|
||||
if (source === 'manual') {
|
||||
@@ -85,49 +60,6 @@ function opt_updateWorldbookSourceVisibility(panel, source) {
|
||||
}
|
||||
}
|
||||
|
||||
async function opt_loadTavernApiProfiles(panel) {
|
||||
const select = panel.find('#amily2_opt_tavern_api_profile_select');
|
||||
const apiSettings = opt_getMergedSettings();
|
||||
const currentProfileId = apiSettings.plotOpt_tavernProfile;
|
||||
|
||||
const currentValue = select.val();
|
||||
select.empty().append(new Option('-- 请选择一个酒馆预设 --', ''));
|
||||
|
||||
try {
|
||||
const tavernProfiles = getContext().extensionSettings?.connectionManager?.profiles || [];
|
||||
if (!tavernProfiles || tavernProfiles.length === 0) {
|
||||
select.append($('<option>', { value: '', text: '未找到酒馆预设', disabled: true }));
|
||||
return;
|
||||
}
|
||||
|
||||
let foundCurrentProfile = false;
|
||||
tavernProfiles.forEach(profile => {
|
||||
if (profile.api && profile.preset) {
|
||||
const option = $('<option>', {
|
||||
value: profile.id,
|
||||
text: profile.name || profile.id,
|
||||
selected: profile.id === currentProfileId
|
||||
});
|
||||
select.append(option);
|
||||
if (profile.id === currentProfileId) {
|
||||
foundCurrentProfile = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (currentProfileId && !foundCurrentProfile) {
|
||||
toastr.warning(`之前选择的酒馆预设 "${currentProfileId}" 已不存在,请重新选择。`);
|
||||
opt_saveSetting('tavernProfile', '');
|
||||
} else if (foundCurrentProfile) {
|
||||
select.val(currentProfileId);
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error(`[${extensionName}] 加载酒馆API预设失败:`, error);
|
||||
toastr.error('无法加载酒馆API预设列表,请查看控制台。');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const opt_characterSpecificSettings = [
|
||||
'plotOpt_worldbookSource',
|
||||
@@ -640,27 +572,9 @@ function opt_loadSettings(panel) {
|
||||
panel.find('#amily2_opt_table_enabled').val(tableEnabledValue);
|
||||
|
||||
panel.find('#amily2_opt_ejs_enabled').prop('checked', settings.plotOpt_ejsEnabled);
|
||||
panel.find(`input[name="amily2_opt_api_mode"][value="${settings.plotOpt_apiMode}"]`).prop('checked', true);
|
||||
panel.find('#amily2_opt_tavern_api_profile_select').val(settings.plotOpt_tavernProfile);
|
||||
panel.find(`input[name="amily2_opt_worldbook_source"][value="${settings.plotOpt_worldbookSource || 'character'}"]`).prop('checked', true);
|
||||
panel.find('#amily2_opt_worldbook_enabled').prop('checked', settings.plotOpt_worldbookEnabled);
|
||||
panel.find('#amily2_opt_new_memory_logic_enabled').prop('checked', settings.plotOpt_newMemoryLogicEnabled);
|
||||
panel.find('#amily2_opt_api_url').val(settings.plotOpt_apiUrl);
|
||||
// plotOpt_apiKey 是敏感字段,从 configManager(localStorage)读取
|
||||
panel.find('#amily2_opt_api_key').val(configManager.get('plotOpt_apiKey') || '');
|
||||
|
||||
const modelInput = panel.find('#amily2_opt_model');
|
||||
const modelSelect = panel.find('#amily2_opt_model_select');
|
||||
|
||||
modelInput.val(settings.plotOpt_model);
|
||||
modelSelect.empty();
|
||||
if (settings.plotOpt_model) {
|
||||
modelSelect.append(new Option(settings.plotOpt_model, settings.plotOpt_model, true, true));
|
||||
} else {
|
||||
modelSelect.append(new Option('<-请先获取模型', '', true, true));
|
||||
}
|
||||
|
||||
syncModelMirror(modelInput.get(0), modelSelect.get(0));
|
||||
panel.find('#amily2_opt_top_p').val(settings.plotOpt_top_p);
|
||||
panel.find('#amily2_opt_presence_penalty').val(settings.plotOpt_presence_penalty);
|
||||
panel.find('#amily2_opt_frequency_penalty').val(settings.plotOpt_frequency_penalty);
|
||||
@@ -690,7 +604,6 @@ function opt_loadSettings(panel) {
|
||||
}, 0);
|
||||
}
|
||||
|
||||
opt_updateApiUrlVisibility(panel, settings.plotOpt_apiMode);
|
||||
opt_updateWorldbookSourceVisibility(panel, settings.plotOpt_worldbookSource || 'character');
|
||||
|
||||
opt_bindSlider(panel, '#amily2_opt_top_p', '#amily2_opt_top_p_value');
|
||||
@@ -703,7 +616,6 @@ function opt_loadSettings(panel) {
|
||||
opt_loadWorldbookEntries(panel);
|
||||
});
|
||||
|
||||
opt_loadTavernApiProfiles(panel);
|
||||
}
|
||||
|
||||
|
||||
@@ -1219,17 +1131,13 @@ export function initializePlotOptimizationBindings() {
|
||||
opt_saveSetting(key, value);
|
||||
}
|
||||
|
||||
if (key === 'plotOpt_api_mode') {
|
||||
opt_updateApiUrlVisibility(panel, value);
|
||||
}
|
||||
|
||||
if (element.name === 'amily2_opt_worldbook_source') {
|
||||
opt_updateWorldbookSourceVisibility(panel, value);
|
||||
opt_loadWorldbookEntries(panel);
|
||||
}
|
||||
};
|
||||
const allInputSelectors = [
|
||||
'input[type="checkbox"]', 'input[type="radio"]', 'select:not(#amily2_opt_model_select)',
|
||||
'input[type="checkbox"]', 'input[type="radio"]', 'select',
|
||||
'input[type="text"]', 'input[type="password"]', 'textarea',
|
||||
'input[type="range"]', 'input[type="number"]'
|
||||
].join(', ');
|
||||
@@ -1238,30 +1146,6 @@ export function initializePlotOptimizationBindings() {
|
||||
handleSettingChange(this);
|
||||
});
|
||||
|
||||
panel.on('input.amily2_opt change.amily2_opt', '#amily2_opt_model', function() {
|
||||
syncModelMirror(
|
||||
panel.find('#amily2_opt_model').get(0),
|
||||
panel.find('#amily2_opt_model_select').get(0)
|
||||
);
|
||||
});
|
||||
|
||||
panel.on('change.amily2_opt', '#amily2_opt_model_select', function() {
|
||||
const selectedModel = $(this).val();
|
||||
if (selectedModel) {
|
||||
panel.find('#amily2_opt_model').val(selectedModel).trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
panel.on('click.amily2_opt', '#amily2_opt_refresh_tavern_api_profiles', () => {
|
||||
opt_loadTavernApiProfiles(panel);
|
||||
});
|
||||
|
||||
panel.on('change.amily2_opt', '#amily2_opt_tavern_api_profile_select', function() {
|
||||
const value = $(this).val();
|
||||
opt_saveSetting('tavernProfile', value);
|
||||
});
|
||||
|
||||
|
||||
panel.find('#amily2_opt_import_prompt_presets').on('click', () => panel.find('#amily2_opt_preset_file_input').click());
|
||||
panel.find('#amily2_opt_export_prompt_presets').on('click', () => opt_exportPromptPresets());
|
||||
@@ -1391,220 +1275,9 @@ export function initializePlotOptimizationBindings() {
|
||||
});
|
||||
}
|
||||
|
||||
// ========== Jqyh API 事件绑定函数 ==========
|
||||
// ========== Jqyh API 事件绑定函数(已迁移至 plotOpt 槽位,此处仅保留空壳) ==========
|
||||
function bindJqyhApiEvents() {
|
||||
console.log("[Amily2号-Jqyh工部] 正在绑定Jqyh API事件...");
|
||||
|
||||
const updateAndSaveSetting = (key, value) => {
|
||||
console.log(`[Amily2-Jqyh令] 收到指令: 将 [${key}] 设置为 ->`, value);
|
||||
if (!extension_settings[extensionName]) {
|
||||
extension_settings[extensionName] = {};
|
||||
}
|
||||
extension_settings[extensionName][key] = value;
|
||||
saveSettingsDebounced();
|
||||
console.log(`[Amily2-Jqyh录] [${key}] 的新状态已保存。`);
|
||||
};
|
||||
|
||||
// Jqyh API 开关控制
|
||||
const jqyhToggle = document.getElementById('amily2_jqyh_enabled');
|
||||
const jqyhContent = document.getElementById('amily2_jqyh_content');
|
||||
|
||||
if (jqyhToggle && jqyhContent) {
|
||||
jqyhToggle.checked = extension_settings[extensionName].jqyhEnabled ?? false;
|
||||
jqyhContent.style.display = jqyhToggle.checked ? 'block' : 'none';
|
||||
|
||||
jqyhToggle.addEventListener('change', function() {
|
||||
const isEnabled = this.checked;
|
||||
updateAndSaveSetting('jqyhEnabled', isEnabled);
|
||||
jqyhContent.style.display = isEnabled ? 'block' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
// API模式切换
|
||||
const apiModeSelect = document.getElementById('amily2_jqyh_api_mode');
|
||||
const compatibleConfig = document.getElementById('amily2_jqyh_compatible_config');
|
||||
const presetConfig = document.getElementById('amily2_jqyh_preset_config');
|
||||
|
||||
if (apiModeSelect && compatibleConfig && presetConfig) {
|
||||
apiModeSelect.value = extension_settings[extensionName].jqyhApiMode || 'openai_test';
|
||||
|
||||
const updateConfigVisibility = (mode) => {
|
||||
if (mode === 'sillytavern_preset') {
|
||||
compatibleConfig.style.display = 'none';
|
||||
presetConfig.style.display = 'block';
|
||||
loadJqyhTavernPresets();
|
||||
} else {
|
||||
compatibleConfig.style.display = 'block';
|
||||
presetConfig.style.display = 'none';
|
||||
}
|
||||
};
|
||||
|
||||
updateConfigVisibility(apiModeSelect.value);
|
||||
|
||||
apiModeSelect.addEventListener('change', function() {
|
||||
updateAndSaveSetting('jqyhApiMode', this.value);
|
||||
updateConfigVisibility(this.value);
|
||||
});
|
||||
}
|
||||
|
||||
// API配置字段绑定
|
||||
const apiFields = [
|
||||
{ id: 'amily2_jqyh_api_url', key: 'jqyhApiUrl' },
|
||||
{ id: 'amily2_jqyh_api_key', key: 'jqyhApiKey', sensitive: true },
|
||||
{ id: 'amily2_jqyh_model', key: 'jqyhModel' }
|
||||
];
|
||||
|
||||
apiFields.forEach(field => {
|
||||
const element = document.getElementById(field.id);
|
||||
if (element) {
|
||||
// 敏感字段(API Key)从 configManager(localStorage)读取
|
||||
element.value = field.sensitive
|
||||
? (configManager.get(field.key) || '')
|
||||
: (extension_settings[extensionName][field.key] || '');
|
||||
const saveField = function() {
|
||||
if (field.sensitive) {
|
||||
configManager.set(field.key, this.value);
|
||||
} else {
|
||||
updateAndSaveSetting(field.key, this.value);
|
||||
if (field.key === 'jqyhModel') {
|
||||
syncModelMirror(
|
||||
document.getElementById('amily2_jqyh_model'),
|
||||
document.getElementById('amily2_jqyh_model_select')
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
bindInputLikeSave(element, saveField);
|
||||
}
|
||||
});
|
||||
|
||||
// 滑块控件绑定
|
||||
const sliderFields = [
|
||||
{ id: 'amily2_jqyh_max_tokens', key: 'jqyhMaxTokens', defaultValue: 4000 },
|
||||
{ id: 'amily2_jqyh_temperature', key: 'jqyhTemperature', defaultValue: 0.7 }
|
||||
];
|
||||
|
||||
sliderFields.forEach(field => {
|
||||
const slider = document.getElementById(field.id);
|
||||
const display = document.getElementById(field.id + '_value');
|
||||
if (slider && display) {
|
||||
const value = extension_settings[extensionName][field.key] || field.defaultValue;
|
||||
slider.value = value;
|
||||
display.textContent = value;
|
||||
|
||||
slider.addEventListener('input', function() {
|
||||
const newValue = parseFloat(this.value);
|
||||
display.textContent = newValue;
|
||||
updateAndSaveSetting(field.key, newValue);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// SillyTavern预设选择器
|
||||
const tavernProfileSelect = document.getElementById('amily2_jqyh_tavern_profile');
|
||||
if (tavernProfileSelect) {
|
||||
tavernProfileSelect.value = extension_settings[extensionName].jqyhTavernProfile || '';
|
||||
tavernProfileSelect.addEventListener('change', function() {
|
||||
updateAndSaveSetting('jqyhTavernProfile', this.value);
|
||||
});
|
||||
}
|
||||
|
||||
// 测试连接按钮
|
||||
const testButton = document.getElementById('amily2_jqyh_test_connection');
|
||||
if (testButton) {
|
||||
testButton.addEventListener('click', async function() {
|
||||
const button = $(this);
|
||||
const originalHtml = button.html();
|
||||
button.prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i> 测试中');
|
||||
|
||||
try {
|
||||
await testJqyhApiConnection();
|
||||
} catch (error) {
|
||||
console.error('[Amily2号-Jqyh] 测试连接失败:', error);
|
||||
} finally {
|
||||
button.prop('disabled', false).html(originalHtml);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const fetchModelsButton = document.getElementById('amily2_jqyh_fetch_models');
|
||||
const modelSelect = document.getElementById('amily2_jqyh_model_select');
|
||||
const modelInput = document.getElementById('amily2_jqyh_model');
|
||||
|
||||
if (fetchModelsButton && modelSelect && modelInput) {
|
||||
fetchModelsButton.addEventListener('click', async function() {
|
||||
const button = $(this);
|
||||
const originalHtml = button.html();
|
||||
button.prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i> 获取中');
|
||||
|
||||
try {
|
||||
const models = await fetchJqyhModels();
|
||||
|
||||
if (models && models.length > 0) {
|
||||
modelSelect.innerHTML = '<option value="">-- 请选择模型 --</option>';
|
||||
models.forEach(model => {
|
||||
const option = document.createElement('option');
|
||||
option.value = model.id || model.name || model;
|
||||
option.textContent = model.name || model.id || model;
|
||||
modelSelect.appendChild(option);
|
||||
});
|
||||
modelSelect.style.display = 'block';
|
||||
modelInput.style.display = 'none';
|
||||
|
||||
modelSelect.addEventListener('change', function() {
|
||||
const selectedModel = this.value;
|
||||
modelInput.value = selectedModel;
|
||||
updateAndSaveSetting('jqyhModel', selectedModel);
|
||||
console.log(`[Amily2-Jqyh] 已选择模型: ${selectedModel}`);
|
||||
});
|
||||
|
||||
toastr.success(`成功获取 ${models.length} 个模型`, 'Jqyh 模型获取');
|
||||
} else {
|
||||
toastr.warning('未获取到任何模型', 'Jqyh 模型获取');
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('[Amily2号-Jqyh] 获取模型列表失败:', error);
|
||||
toastr.error(`获取模型失败: ${error.message}`, 'Jqyh 模型获取');
|
||||
} finally {
|
||||
button.prop('disabled', false).html(originalHtml);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function loadJqyhTavernPresets() {
|
||||
const select = document.getElementById('amily2_jqyh_tavern_profile');
|
||||
if (!select) return;
|
||||
|
||||
const currentValue = select.value;
|
||||
select.innerHTML = '<option value="">-- 加载中 --</option>';
|
||||
|
||||
try {
|
||||
const context = getContext();
|
||||
const tavernProfiles = context.extensionSettings?.connectionManager?.profiles || [];
|
||||
|
||||
select.innerHTML = '<option value="">-- 请选择预设 --</option>';
|
||||
|
||||
if (tavernProfiles.length > 0) {
|
||||
tavernProfiles.forEach(profile => {
|
||||
if (profile.api && profile.preset) {
|
||||
const option = document.createElement('option');
|
||||
option.value = profile.id;
|
||||
option.textContent = profile.name || profile.id;
|
||||
if (profile.id === currentValue) {
|
||||
option.selected = true;
|
||||
}
|
||||
select.appendChild(option);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
select.innerHTML = '<option value="">未找到可用预设</option>';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[Amily2号-Jqyh] 加载SillyTavern预设失败:', error);
|
||||
select.innerHTML = '<option value="">加载失败</option>';
|
||||
}
|
||||
// Jqyh 直连配置已移除,剧情优化统一走 ApiProfile plotOpt 槽位
|
||||
}
|
||||
|
||||
// ========== 图标位置切换(跨模块通用事件) ==========
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
function a0_0x3b40(_0x52863f,_0x598139){_0x52863f=_0x52863f-0x10b;const _0x399b59=a0_0x399b();let _0x3b40b9=_0x399b59[_0x52863f];if(a0_0x3b40['EhwDdC']===undefined){var _0x14ff08=function(_0x51be5a){const _0xc21f70='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x318f72='',_0x15280f='';for(let _0x4eb1ac=0x0,_0xdf062f,_0x336f71,_0x3dbe27=0x0;_0x336f71=_0x51be5a['charAt'](_0x3dbe27++);~_0x336f71&&(_0xdf062f=_0x4eb1ac%0x4?_0xdf062f*0x40+_0x336f71:_0x336f71,_0x4eb1ac++%0x4)?_0x318f72+=String['fromCharCode'](0xff&_0xdf062f>>(-0x2*_0x4eb1ac&0x6)):0x0){_0x336f71=_0xc21f70['indexOf'](_0x336f71);}for(let _0x479e87=0x0,_0x5e403d=_0x318f72['length'];_0x479e87<_0x5e403d;_0x479e87++){_0x15280f+='%'+('00'+_0x318f72['charCodeAt'](_0x479e87)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x15280f);};const _0x7cd2e2=function(_0x5079b0,_0x2a786a){let _0x17841d=[],_0x15faea=0x0,_0x383827,_0x2b33c7='';_0x5079b0=_0x14ff08(_0x5079b0);let _0x472953;for(_0x472953=0x0;_0x472953<0x100;_0x472953++){_0x17841d[_0x472953]=_0x472953;}for(_0x472953=0x0;_0x472953<0x100;_0x472953++){_0x15faea=(_0x15faea+_0x17841d[_0x472953]+_0x2a786a['charCodeAt'](_0x472953%_0x2a786a['length']))%0x100,_0x383827=_0x17841d[_0x472953],_0x17841d[_0x472953]=_0x17841d[_0x15faea],_0x17841d[_0x15faea]=_0x383827;}_0x472953=0x0,_0x15faea=0x0;for(let _0x256392=0x0;_0x256392<_0x5079b0['length'];_0x256392++){_0x472953=(_0x472953+0x1)%0x100,_0x15faea=(_0x15faea+_0x17841d[_0x472953])%0x100,_0x383827=_0x17841d[_0x472953],_0x17841d[_0x472953]=_0x17841d[_0x15faea],_0x17841d[_0x15faea]=_0x383827,_0x2b33c7+=String['fromCharCode'](_0x5079b0['charCodeAt'](_0x256392)^_0x17841d[(_0x17841d[_0x472953]+_0x17841d[_0x15faea])%0x100]);}return _0x2b33c7;};a0_0x3b40['DFoPSr']=_0x7cd2e2,a0_0x3b40['YEajuv']={},a0_0x3b40['EhwDdC']=!![];}const _0x49bd5f=_0x399b59[0x0],_0x20b5cf=_0x52863f+_0x49bd5f,_0x5312cc=a0_0x3b40['YEajuv'][_0x20b5cf];return!_0x5312cc?(a0_0x3b40['hUoguf']===undefined&&(a0_0x3b40['hUoguf']=!![]),_0x3b40b9=a0_0x3b40['DFoPSr'](_0x3b40b9,_0x598139),a0_0x3b40['YEajuv'][_0x20b5cf]=_0x3b40b9):_0x3b40b9=_0x5312cc,_0x3b40b9;}const a0_0x1b65c5=a0_0x3b40;(function(_0x83808a,_0x28aa75){const _0x2691e8=a0_0x3b40,_0x23f642=_0x83808a();while(!![]){try{const _0x3f6f8e=parseInt(_0x2691e8(0x127,'7zr3'))/0x1*(-parseInt(_0x2691e8(0x119,'[M&$'))/0x2)+-parseInt(_0x2691e8(0x11c,'sG)e'))/0x3*(parseInt(_0x2691e8(0x114,'#Pe^'))/0x4)+parseInt(_0x2691e8(0x120,'pAQS'))/0x5+-parseInt(_0x2691e8(0x110,')OMX'))/0x6+-parseInt(_0x2691e8(0x10e,'^Fo0'))/0x7*(-parseInt(_0x2691e8(0x10f,')De%'))/0x8)+-parseInt(_0x2691e8(0x10d,'1bb9'))/0x9*(-parseInt(_0x2691e8(0x113,'jnhv'))/0xa)+-parseInt(_0x2691e8(0x129,'I5i*'))/0xb*(-parseInt(_0x2691e8(0x118,'sG)e'))/0xc);if(_0x3f6f8e===_0x28aa75)break;else _0x23f642['push'](_0x23f642['shift']());}catch(_0x382331){_0x23f642['push'](_0x23f642['shift']());}}}(a0_0x399b,0x34593));export const SENSITIVE_KEYS=new Set([a0_0x1b65c5(0x125,'HHVc'),a0_0x1b65c5(0x115,'o2#t'),a0_0x1b65c5(0x122,')De%'),a0_0x1b65c5(0x128,'1G#I'),a0_0x1b65c5(0x112,'R%T)'),a0_0x1b65c5(0x124,'t441'),a0_0x1b65c5(0x11a,'GBUk'),a0_0x1b65c5(0x11f,'rYY2')]);function a0_0x399b(){const _0x102bff=['W5OuldLYWPCmjSoEWQaNWO8','WQ4DW6DbW4vnDszDyIqbdGG','W7JdGSkVWQm/WO7cPHXBWR0sW60','jbFcOvZdG8oIDWJdOqyjmGy','WOldL8kEoSk4eXXUW7ZdHrhcISol','W5j7sCodvuH6','wIRcS8k3W4BcJ8kxgrmtWPe','bvddQ8ozlCo1p8kzBs3cIJf8','WONcUCofz8obxvK','WPWlW6NcVmk+WOvs','rmkAW5a0W51kW4q0oSkLW4zL','DmkICSogWQlcTSk2WOWmW7y','WOLLdmkhgCkzW7jIWQ3cO3DKda','WPtdQc4GzG3cOfG','WRLCevHDWQ9hWRBcLCkMoComWP/cRLVdICohCCkaW4DhvZRcKa','AGnBWPFdMa7dMta','lCoDWPGdW5BdUmoCW5Hwca','WOrEW4XUCXS','mefWWOJcKf4wW5RcS8oSd8kF','WPdcMCkZa8kXASkNv8k/W5LfW6S','tMyVWR7cSrRdMJO9aW','kSo5W65ldCkBWPP/','WPDLWRldOCohW4SxemkzW7rYCZ4','FWVcHZvlWRhdSa','FL5SrCkFvmkN','yKT6WPJdQX/dVq','W5ZdKandWRPgWPPF','W7GdsHqIW694WRdcS8kRdSo6','W7yLuhlcOmoBpsCpWR7cGCkGWQy','W6JcUZ9/CmkShSk3D8oYW7BdKb4','pConW4e9W7NcG8oHgriJ','W69BqMDnW4GGzae0vmodWQa'];a0_0x399b=function(){return _0x102bff;};return a0_0x399b();}
|
||||
const a0_0x31e962=a0_0x4c2c;(function(_0xb18088,_0x3dccea){const _0x2301d5=a0_0x4c2c,_0x1d8c5a=_0xb18088();while(!![]){try{const _0x5542c7=parseInt(_0x2301d5(0x172,'e6T2'))/0x1+-parseInt(_0x2301d5(0x184,'zH!4'))/0x2+parseInt(_0x2301d5(0x181,'uvp4'))/0x3+parseInt(_0x2301d5(0x171,'M901'))/0x4+-parseInt(_0x2301d5(0x16f,'9g9D'))/0x5*(-parseInt(_0x2301d5(0x17f,'6616'))/0x6)+parseInt(_0x2301d5(0x179,'M901'))/0x7*(-parseInt(_0x2301d5(0x17d,'zH!4'))/0x8)+-parseInt(_0x2301d5(0x174,'Xue!'))/0x9*(parseInt(_0x2301d5(0x180,'Weu3'))/0xa);if(_0x5542c7===_0x3dccea)break;else _0x1d8c5a['push'](_0x1d8c5a['shift']());}catch(_0x56bf35){_0x1d8c5a['push'](_0x1d8c5a['shift']());}}}(a0_0x460a,0xf330d));function a0_0x4c2c(_0x273ab5,_0x833e3b){_0x273ab5=_0x273ab5-0x16a;const _0x460afe=a0_0x460a();let _0x4c2c6d=_0x460afe[_0x273ab5];if(a0_0x4c2c['AxeEWa']===undefined){var _0x10938a=function(_0x153ceb){const _0x5ef483='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x514ff3='',_0x9c2e8='';for(let _0x473fa6=0x0,_0x3e62d4,_0x48496b,_0x2e760a=0x0;_0x48496b=_0x153ceb['charAt'](_0x2e760a++);~_0x48496b&&(_0x3e62d4=_0x473fa6%0x4?_0x3e62d4*0x40+_0x48496b:_0x48496b,_0x473fa6++%0x4)?_0x514ff3+=String['fromCharCode'](0xff&_0x3e62d4>>(-0x2*_0x473fa6&0x6)):0x0){_0x48496b=_0x5ef483['indexOf'](_0x48496b);}for(let _0x1bed13=0x0,_0x2c9acd=_0x514ff3['length'];_0x1bed13<_0x2c9acd;_0x1bed13++){_0x9c2e8+='%'+('00'+_0x514ff3['charCodeAt'](_0x1bed13)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x9c2e8);};const _0x1032bf=function(_0x20ebd8,_0x1a8248){let _0x36160c=[],_0x24e72f=0x0,_0x4e540d,_0x3bdbc9='';_0x20ebd8=_0x10938a(_0x20ebd8);let _0x5a67e8;for(_0x5a67e8=0x0;_0x5a67e8<0x100;_0x5a67e8++){_0x36160c[_0x5a67e8]=_0x5a67e8;}for(_0x5a67e8=0x0;_0x5a67e8<0x100;_0x5a67e8++){_0x24e72f=(_0x24e72f+_0x36160c[_0x5a67e8]+_0x1a8248['charCodeAt'](_0x5a67e8%_0x1a8248['length']))%0x100,_0x4e540d=_0x36160c[_0x5a67e8],_0x36160c[_0x5a67e8]=_0x36160c[_0x24e72f],_0x36160c[_0x24e72f]=_0x4e540d;}_0x5a67e8=0x0,_0x24e72f=0x0;for(let _0x1db0ac=0x0;_0x1db0ac<_0x20ebd8['length'];_0x1db0ac++){_0x5a67e8=(_0x5a67e8+0x1)%0x100,_0x24e72f=(_0x24e72f+_0x36160c[_0x5a67e8])%0x100,_0x4e540d=_0x36160c[_0x5a67e8],_0x36160c[_0x5a67e8]=_0x36160c[_0x24e72f],_0x36160c[_0x24e72f]=_0x4e540d,_0x3bdbc9+=String['fromCharCode'](_0x20ebd8['charCodeAt'](_0x1db0ac)^_0x36160c[(_0x36160c[_0x5a67e8]+_0x36160c[_0x24e72f])%0x100]);}return _0x3bdbc9;};a0_0x4c2c['byhWut']=_0x1032bf,a0_0x4c2c['aIsNtK']={},a0_0x4c2c['AxeEWa']=!![];}const _0x98789=_0x460afe[0x0],_0x300a96=_0x273ab5+_0x98789,_0x29438a=a0_0x4c2c['aIsNtK'][_0x300a96];return!_0x29438a?(a0_0x4c2c['AlrPtr']===undefined&&(a0_0x4c2c['AlrPtr']=!![]),_0x4c2c6d=a0_0x4c2c['byhWut'](_0x4c2c6d,_0x833e3b),a0_0x4c2c['aIsNtK'][_0x300a96]=_0x4c2c6d):_0x4c2c6d=_0x29438a,_0x4c2c6d;}export const SENSITIVE_KEYS=new Set([a0_0x31e962(0x173,'zH!4'),a0_0x31e962(0x177,'9g9D'),a0_0x31e962(0x170,'9g9D'),a0_0x31e962(0x17a,'Weu3'),a0_0x31e962(0x16b,'Weu3'),a0_0x31e962(0x183,'QTt6'),a0_0x31e962(0x175,'wKYv'),a0_0x31e962(0x182,'SRqH')]);function a0_0x460a(){const _0x5b1173=['xqhdRaNdVmkaW69fW61x','oetcHrurpCkXkghcHa','xaVdRa3cL8oGWRnaW7negvmY','W7NdKmoqtSoslSkVW7v+yCoNjwy','WPD5j8oqvCoUW45wW5zwqeK','oMDTW5u+xCoPCq','Et5mW4S2ECosyCo8tmobWRRdVmoSWP3cJKfPW7aJcLdcKCoy','hW8oBIfWxmkHgCksrSoSkW','BfmrW77dU1WTWRLpwMLgW4e','gmoXzmokAd8','qCkjWQK2W7hcKgKDoqS','ucnZWOldM8kfWPrXphSm','jmkHa8k7WQS5WPSMhG','Et5mW4S2ECosyCo+u8ogWPldRmoN','wCoyCHpdL1/cP0S','haSopv8bcmkXma','oedcIXurpCkXkghcHa','mSo/W50yW6bVhcFdUNHR','WRldHCoFW5pcU8kBi8kUWR/cGvK','s8k2pSk0pXr1W77cKgKO','nu58eSovWRxcLCk9WPtdO8owpwa','W4xcLKldTuZdOwBdPmo1zmk3W4G','zbddLfbGoCkVef3cNWO','cCojeSkPWQn3W7tdMmkJAmk1W5jM','WRJcNCkhhmkNz8o0W4PJxq','WPtcLgpcLgpcPSkIW6jeWRW','sSk4pSk1p3mnW5NcTw4jWQ3cMq','nmkzWO8GrLnrxSkUyGWeW6e'];a0_0x460a=function(){return _0x5b1173;};return a0_0x460a();}
|
||||
Reference in New Issue
Block a user