Add files via upload

This commit is contained in:
2025-10-26 04:59:30 +08:00
committed by GitHub
parent e7522e1e49
commit 5c0bf694fd
4 changed files with 1538 additions and 1550 deletions

View File

@@ -1,6 +1,7 @@
import { extension_settings, getContext } from "/scripts/extensions.js";
import { characters, this_chid, getRequestHeaders, saveSettingsDebounced, eventSource, event_types } from "/script.js";
import { extensionName } from "../../utils/settings.js";
import { amilyHelper } from '../../core/tavern-helper/main.js';
let ChatCompletionService = undefined;
try {
@@ -184,10 +185,6 @@ async function callJqyhOpenAITest(messages, options) {
async function callJqyhSillyTavernPreset(messages, options) {
console.log('[Amily2号-JqyhST预设] 使用SillyTavern预设调用');
if (!window.TavernHelper || !window.TavernHelper.triggerSlash) {
throw new Error('TavernHelper不可用无法使用SillyTavern预设模式');
}
const context = getContext();
if (!context) {
throw new Error('无法获取SillyTavern上下文');
@@ -202,7 +199,7 @@ async function callJqyhSillyTavernPreset(messages, options) {
let responsePromise;
try {
originalProfile = await window.TavernHelper.triggerSlash('/profile');
originalProfile = await amilyHelper.triggerSlash('/profile');
console.log(`[Amily2号-JqyhST预设] 当前配置文件: ${originalProfile}`);
const targetProfile = context.extensionSettings?.connectionManager?.profiles?.find(p => p.id === profileId);
@@ -213,11 +210,11 @@ async function callJqyhSillyTavernPreset(messages, options) {
const targetProfileName = targetProfile.name;
console.log(`[Amily2号-JqyhST预设] 目标配置文件: ${targetProfileName}`);
const currentProfile = await window.TavernHelper.triggerSlash('/profile');
const currentProfile = await amilyHelper.triggerSlash('/profile');
if (currentProfile !== targetProfileName) {
console.log(`[Amily2号-JqyhST预设] 切换配置文件: ${currentProfile} -> ${targetProfileName}`);
const escapedProfileName = targetProfileName.replace(/"/g, '\\"');
await window.TavernHelper.triggerSlash(`/profile await=true "${escapedProfileName}"`);
await amilyHelper.triggerSlash(`/profile await=true "${escapedProfileName}"`);
}
if (!context.ConnectionManagerRequestService) {
@@ -233,11 +230,11 @@ async function callJqyhSillyTavernPreset(messages, options) {
} finally {
try {
const currentProfileAfterCall = await window.TavernHelper.triggerSlash('/profile');
const currentProfileAfterCall = await amilyHelper.triggerSlash('/profile');
if (originalProfile && originalProfile !== currentProfileAfterCall) {
console.log(`[Amily2号-JqyhST预设] 恢复原始配置文件: ${currentProfileAfterCall} -> ${originalProfile}`);
const escapedOriginalProfile = originalProfile.replace(/"/g, '\\"');
await window.TavernHelper.triggerSlash(`/profile await=true "${escapedOriginalProfile}"`);
await amilyHelper.triggerSlash(`/profile await=true "${escapedOriginalProfile}"`);
}
} catch (restoreError) {
console.error('[Amily2号-JqyhST预设] 恢复配置文件失败:', restoreError);

View File

@@ -1,6 +1,7 @@
import { extension_settings, getContext } from "/scripts/extensions.js";
import { characters, this_chid, getRequestHeaders, saveSettingsDebounced, eventSource, event_types } from "/script.js";
import { extensionName } from "../../utils/settings.js";
import { amilyHelper } from '../../core/tavern-helper/main.js';
let ChatCompletionService = undefined;
try {
@@ -184,10 +185,6 @@ async function callNccsOpenAITest(messages, options) {
async function callNccsSillyTavernPreset(messages, options) {
console.log('[Amily2号-NccsST预设] 使用SillyTavern预设调用');
if (!window.TavernHelper || !window.TavernHelper.triggerSlash) {
throw new Error('TavernHelper不可用无法使用SillyTavern预设模式');
}
const context = getContext();
if (!context) {
throw new Error('无法获取SillyTavern上下文');
@@ -202,7 +199,7 @@ async function callNccsSillyTavernPreset(messages, options) {
let responsePromise;
try {
originalProfile = await window.TavernHelper.triggerSlash('/profile');
originalProfile = await amilyHelper.triggerSlash('/profile');
console.log(`[Amily2号-NccsST预设] 当前配置文件: ${originalProfile}`);
const targetProfile = context.extensionSettings?.connectionManager?.profiles?.find(p => p.id === profileId);
@@ -213,11 +210,11 @@ async function callNccsSillyTavernPreset(messages, options) {
const targetProfileName = targetProfile.name;
console.log(`[Amily2号-NccsST预设] 目标配置文件: ${targetProfileName}`);
const currentProfile = await window.TavernHelper.triggerSlash('/profile');
const currentProfile = await amilyHelper.triggerSlash('/profile');
if (currentProfile !== targetProfileName) {
console.log(`[Amily2号-NccsST预设] 切换配置文件: ${currentProfile} -> ${targetProfileName}`);
const escapedProfileName = targetProfileName.replace(/"/g, '\\"');
await window.TavernHelper.triggerSlash(`/profile await=true "${escapedProfileName}"`);
await amilyHelper.triggerSlash(`/profile await=true "${escapedProfileName}"`);
}
if (!context.ConnectionManagerRequestService) {
@@ -233,11 +230,11 @@ async function callNccsSillyTavernPreset(messages, options) {
} finally {
try {
const currentProfileAfterCall = await window.TavernHelper.triggerSlash('/profile');
const currentProfileAfterCall = await amilyHelper.triggerSlash('/profile');
if (originalProfile && originalProfile !== currentProfileAfterCall) {
console.log(`[Amily2号-NccsST预设] 恢复原始配置文件: ${currentProfileAfterCall} -> ${originalProfile}`);
const escapedOriginalProfile = originalProfile.replace(/"/g, '\\"');
await window.TavernHelper.triggerSlash(`/profile await=true "${escapedOriginalProfile}"`);
await amilyHelper.triggerSlash(`/profile await=true "${escapedOriginalProfile}"`);
}
} catch (restoreError) {
console.error('[Amily2号-NccsST预设] 恢复配置文件失败:', restoreError);

View File

@@ -1,6 +1,7 @@
import { extension_settings, getContext } from "/scripts/extensions.js";
import { characters, this_chid, getRequestHeaders, saveSettingsDebounced, eventSource, event_types } from "/script.js";
import { extensionName } from "../../utils/settings.js";
import { amilyHelper } from '../../core/tavern-helper/main.js';
let ChatCompletionService = undefined;
try {
@@ -184,10 +185,6 @@ async function callNgmsOpenAITest(messages, options) {
async function callNgmsSillyTavernPreset(messages, options) {
console.log('[Amily2号-NgmsST预设] 使用SillyTavern预设调用');
if (!window.TavernHelper || !window.TavernHelper.triggerSlash) {
throw new Error('TavernHelper不可用无法使用SillyTavern预设模式');
}
const context = getContext();
if (!context) {
throw new Error('无法获取SillyTavern上下文');
@@ -202,7 +199,7 @@ async function callNgmsSillyTavernPreset(messages, options) {
let responsePromise;
try {
originalProfile = await window.TavernHelper.triggerSlash('/profile');
originalProfile = await amilyHelper.triggerSlash('/profile');
console.log(`[Amily2号-NgmsST预设] 当前配置文件: ${originalProfile}`);
const targetProfile = context.extensionSettings?.connectionManager?.profiles?.find(p => p.id === profileId);
@@ -213,11 +210,11 @@ async function callNgmsSillyTavernPreset(messages, options) {
const targetProfileName = targetProfile.name;
console.log(`[Amily2号-NgmsST预设] 目标配置文件: ${targetProfileName}`);
const currentProfile = await window.TavernHelper.triggerSlash('/profile');
const currentProfile = await amilyHelper.triggerSlash('/profile');
if (currentProfile !== targetProfileName) {
console.log(`[Amily2号-NgmsST预设] 切换配置文件: ${currentProfile} -> ${targetProfileName}`);
const escapedProfileName = targetProfileName.replace(/"/g, '\\"');
await window.TavernHelper.triggerSlash(`/profile await=true "${escapedProfileName}"`);
await amilyHelper.triggerSlash(`/profile await=true "${escapedProfileName}"`);
}
if (!context.ConnectionManagerRequestService) {
@@ -233,11 +230,11 @@ async function callNgmsSillyTavernPreset(messages, options) {
} finally {
try {
const currentProfileAfterCall = await window.TavernHelper.triggerSlash('/profile');
const currentProfileAfterCall = await amilyHelper.triggerSlash('/profile');
if (originalProfile && originalProfile !== currentProfileAfterCall) {
console.log(`[Amily2号-NgmsST预设] 恢复原始配置文件: ${currentProfileAfterCall} -> ${originalProfile}`);
const escapedOriginalProfile = originalProfile.replace(/"/g, '\\"');
await window.TavernHelper.triggerSlash(`/profile await=true "${escapedOriginalProfile}"`);
await amilyHelper.triggerSlash(`/profile await=true "${escapedOriginalProfile}"`);
}
} catch (restoreError) {
console.error('[Amily2号-NgmsST预设] 恢复配置文件失败:', restoreError);

View File

@@ -1,6 +1,7 @@
import { extension_settings, getContext } from "/scripts/extensions.js";
import { characters, this_chid, getRequestHeaders, saveSettingsDebounced, eventSource, event_types } from "/script.js";
import { extensionName } from "../../utils/settings.js";
import { amilyHelper } from '../../core/tavern-helper/main.js';
let ChatCompletionService = undefined;
try {
@@ -184,10 +185,6 @@ async function callSybdOpenAITest(messages, options) {
async function callSybdSillyTavernPreset(messages, options) {
console.log('[Amily2号-SybdST预设] 使用SillyTavern预设调用');
if (!window.TavernHelper || !window.TavernHelper.triggerSlash) {
throw new Error('TavernHelper不可用无法使用SillyTavern预设模式');
}
const context = getContext();
if (!context) {
throw new Error('无法获取SillyTavern上下文');
@@ -202,7 +199,7 @@ async function callSybdSillyTavernPreset(messages, options) {
let responsePromise;
try {
originalProfile = await window.TavernHelper.triggerSlash('/profile');
originalProfile = await amilyHelper.triggerSlash('/profile');
console.log(`[Amily2号-SybdST预设] 当前配置文件: ${originalProfile}`);
const targetProfile = context.extensionSettings?.connectionManager?.profiles?.find(p => p.id === profileId);
@@ -213,11 +210,11 @@ async function callSybdSillyTavernPreset(messages, options) {
const targetProfileName = targetProfile.name;
console.log(`[Amily2号-SybdST预设] 目标配置文件: ${targetProfileName}`);
const currentProfile = await window.TavernHelper.triggerSlash('/profile');
const currentProfile = await amilyHelper.triggerSlash('/profile');
if (currentProfile !== targetProfileName) {
console.log(`[Amily2号-SybdST预设] 切换配置文件: ${currentProfile} -> ${targetProfileName}`);
const escapedProfileName = targetProfileName.replace(/"/g, '\\"');
await window.TavernHelper.triggerSlash(`/profile await=true "${escapedProfileName}"`);
await amilyHelper.triggerSlash(`/profile await=true "${escapedProfileName}"`);
}
if (!context.ConnectionManagerRequestService) {
@@ -233,11 +230,11 @@ async function callSybdSillyTavernPreset(messages, options) {
} finally {
try {
const currentProfileAfterCall = await window.TavernHelper.triggerSlash('/profile');
const currentProfileAfterCall = await amilyHelper.triggerSlash('/profile');
if (originalProfile && originalProfile !== currentProfileAfterCall) {
console.log(`[Amily2号-SybdST预设] 恢复原始配置文件: ${currentProfileAfterCall} -> ${originalProfile}`);
const escapedOriginalProfile = originalProfile.replace(/"/g, '\\"');
await window.TavernHelper.triggerSlash(`/profile await=true "${escapedOriginalProfile}"`);
await amilyHelper.triggerSlash(`/profile await=true "${escapedOriginalProfile}"`);
}
} catch (restoreError) {
console.error('[Amily2号-SybdST预设] 恢复配置文件失败:', restoreError);