mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-07 09:25:51 +00:00
Merge pull request #3 from SilenceLurker/main
Update cwb_lorebookManager
This commit is contained in:
@@ -184,7 +184,7 @@ function createCharCardViewerPopupHtml(displayItems) {
|
||||
}
|
||||
|
||||
function bindCharCardViewerPopupEvents($popup) {
|
||||
$popup.on('change', '.cwb-insertion-position', function() {
|
||||
$popup.on('change', '.cwb-insertion-position', function () {
|
||||
const $this = $(this);
|
||||
const $depthContainer = $this.closest('.cwb-insertion-settings-content').find('.cwb-insertion-depth-container');
|
||||
if ($this.val() === 'at_depth') {
|
||||
@@ -200,7 +200,7 @@ function bindCharCardViewerPopupEvents($popup) {
|
||||
showCharCardViewerPopup();
|
||||
});
|
||||
|
||||
$popup.find('#cwb-manual-update-btn').on('click', async function() {
|
||||
$popup.find('#cwb-manual-update-btn').on('click', async function () {
|
||||
const $button = $(this);
|
||||
$button.prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i> 更新中...');
|
||||
await manualUpdateLogic();
|
||||
@@ -217,7 +217,7 @@ function bindCharCardViewerPopupEvents($popup) {
|
||||
$popup.find(`#cwb-char-content-${targetUid}`).addClass('active');
|
||||
});
|
||||
|
||||
$popup.find('.cwb-cyber-tab__delete').on('click', async function(e) {
|
||||
$popup.find('.cwb-cyber-tab__delete').on('click', async function (e) {
|
||||
e.stopPropagation();
|
||||
if (confirm('您确定要删除这个角色条目吗?此操作不可撤销。')) {
|
||||
const uidToDelete = $(this).data('char-uid');
|
||||
@@ -235,9 +235,9 @@ function bindCharCardViewerPopupEvents($popup) {
|
||||
}
|
||||
});
|
||||
|
||||
$popup.find('#cwb-viewer-delete-all').on('click', async function() {
|
||||
$popup.find('#cwb-viewer-delete-all').on('click', async function () {
|
||||
if (confirm('您确定要清除当前聊天中的所有角色卡和总览吗?此操作将删除所有相关条目,且不可撤销。')) {
|
||||
const allUids = $popup.find('.cwb-cyber-tab__button').map(function() {
|
||||
const allUids = $popup.find('.cwb-cyber-tab__button').map(function () {
|
||||
return $(this).data('char-uid');
|
||||
}).get();
|
||||
if (allUids.length > 0) {
|
||||
@@ -278,10 +278,18 @@ function bindCharCardViewerPopupEvents($popup) {
|
||||
if ($field.data('is-array')) {
|
||||
value = value.split('\n').map(l => l.trim()).filter(Boolean);
|
||||
}
|
||||
if(path){
|
||||
setNestedValue(collectedData, path, value);
|
||||
if (path) {
|
||||
setNestedValue(collectedData, path, value);
|
||||
}
|
||||
});
|
||||
let localTavernHelper = TavernHelper;
|
||||
if (!localTavernHelper) {
|
||||
// TavernHelper 未定义的情况下触发,但是为什么?
|
||||
(localTavernHelper = window.TavernHelper);
|
||||
if (localTavernHelper) {
|
||||
TavernHelper = localTavernHelper;
|
||||
}
|
||||
}
|
||||
const finalContentToSave = buildCustomFormat(collectedData);
|
||||
const allEntries = await TavernHelper.getLorebookEntries(book);
|
||||
const entryToUpdate = allEntries.find(e => e.uid === targetUid);
|
||||
@@ -326,7 +334,14 @@ function bindCharCardViewerPopupEvents($popup) {
|
||||
order: finalEntryData.order,
|
||||
hasDepthField: 'depth' in finalEntryData
|
||||
});
|
||||
|
||||
localTavernHelper = TavernHelper;
|
||||
if (!localTavernHelper) {
|
||||
// TavernHelper 未定义的情况下触发,但是为什么?
|
||||
(localTavernHelper = window.TavernHelper);
|
||||
if (localTavernHelper) {
|
||||
TavernHelper = localTavernHelper;
|
||||
}
|
||||
}
|
||||
await TavernHelper.setLorebookEntries(book, [finalEntryData]);
|
||||
showToastr('success', '角色卡已成功保存!');
|
||||
} catch (error) {
|
||||
@@ -353,6 +368,14 @@ export async function showCharCardViewerPopup() {
|
||||
bindCharCardViewerPopupEvents($(`#${CHAR_CARD_VIEWER_POPUP_ID}`));
|
||||
return;
|
||||
}
|
||||
let localTavernHelper = TavernHelper;
|
||||
if (!localTavernHelper) {
|
||||
// TavernHelper 未定义的情况下触发,但是为什么?
|
||||
(localTavernHelper = window.TavernHelper);
|
||||
if (localTavernHelper) {
|
||||
TavernHelper = localTavernHelper;
|
||||
}
|
||||
}
|
||||
const allEntries = await TavernHelper.getLorebookEntries(book);
|
||||
let currentChatId = state.currentChatFileIdentifier;
|
||||
|
||||
@@ -618,39 +641,39 @@ export function updateViewerButtonVisibility() {
|
||||
export function bindCwbApiEvents() {
|
||||
console.log('[CWB] Binding API events');
|
||||
|
||||
$('#cwb-api-url').off('input').on('input', function() {
|
||||
$('#cwb-api-url').off('input').on('input', function () {
|
||||
const value = $(this).val();
|
||||
extension_settings[extensionName].cwb_api_url = value;
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#cwb-api-key').off('input').on('input', function() {
|
||||
$('#cwb-api-key').off('input').on('input', function () {
|
||||
const value = $(this).val();
|
||||
extension_settings[extensionName].cwb_api_key = value;
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#cwb-model').off('input').on('input', function() {
|
||||
$('#cwb-model').off('input').on('input', function () {
|
||||
const value = $(this).val();
|
||||
extension_settings[extensionName].cwb_model = value;
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#cwb-temperature').off('input').on('input', function() {
|
||||
$('#cwb-temperature').off('input').on('input', function () {
|
||||
const value = parseFloat($(this).val());
|
||||
$('#cwb-temperature-value').text(value);
|
||||
extension_settings[extensionName].cwb_temperature = value;
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#cwb-max-tokens').off('input').on('input', function() {
|
||||
$('#cwb-max-tokens').off('input').on('input', function () {
|
||||
const value = parseInt($(this).val());
|
||||
$('#cwb-max-tokens-value').text(value);
|
||||
extension_settings[extensionName].cwb_max_tokens = value;
|
||||
saveSettingsDebounced();
|
||||
});
|
||||
|
||||
$('#cwb-test-connection').off('click').on('click', async function() {
|
||||
$('#cwb-test-connection').off('click').on('click', async function () {
|
||||
const $button = $(this);
|
||||
$button.prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i> 测试中...');
|
||||
|
||||
@@ -663,7 +686,7 @@ export function bindCwbApiEvents() {
|
||||
}
|
||||
});
|
||||
|
||||
$('#cwb-fetch-models').off('click').on('click', async function() {
|
||||
$('#cwb-fetch-models').off('click').on('click', async function () {
|
||||
const $button = $(this);
|
||||
$button.prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i> 获取中...');
|
||||
|
||||
|
||||
33
TODO.md
Normal file
33
TODO.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# TODO List
|
||||
|
||||
该文件用于记录开发项目及未修改bug,以及修改内容清单。
|
||||
|
||||
## 待开发
|
||||
|
||||
以下为示例(预计三个版本后移除)
|
||||
|
||||
- 示例:未完成功能——负责人
|
||||
- 示例:向量化优先检索池功能开发——49
|
||||
|
||||
---
|
||||
|
||||
以下为待开发内容
|
||||
|
||||
## 未修复
|
||||
|
||||
以下为示例(预计三个版本后移除)
|
||||
|
||||
- 示例:未完成bug——负责人
|
||||
- 示例:TavernHelper异常undefined导致角色世界书读取异常——Silence_Lurker潜默
|
||||
- ~~示例:已完成修复bug——负责人~~
|
||||
|
||||
---
|
||||
|
||||
以下为记录内容
|
||||
|
||||
## 版本修复/开发日志
|
||||
|
||||
### 1.5.7?
|
||||
|
||||
- 添加了**TODO.md**,现在可以记录任务清单并更清楚的记录开发完成状态了。
|
||||
- 无实际功能更新
|
||||
Reference in New Issue
Block a user