mirror of
https://github.com/SilenceLurker/ST-Amily2-Chat-Optimisation.git
synced 2026-06-06 15:55:50 +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) {
|
function bindCharCardViewerPopupEvents($popup) {
|
||||||
$popup.on('change', '.cwb-insertion-position', function() {
|
$popup.on('change', '.cwb-insertion-position', function () {
|
||||||
const $this = $(this);
|
const $this = $(this);
|
||||||
const $depthContainer = $this.closest('.cwb-insertion-settings-content').find('.cwb-insertion-depth-container');
|
const $depthContainer = $this.closest('.cwb-insertion-settings-content').find('.cwb-insertion-depth-container');
|
||||||
if ($this.val() === 'at_depth') {
|
if ($this.val() === 'at_depth') {
|
||||||
@@ -200,7 +200,7 @@ function bindCharCardViewerPopupEvents($popup) {
|
|||||||
showCharCardViewerPopup();
|
showCharCardViewerPopup();
|
||||||
});
|
});
|
||||||
|
|
||||||
$popup.find('#cwb-manual-update-btn').on('click', async function() {
|
$popup.find('#cwb-manual-update-btn').on('click', async function () {
|
||||||
const $button = $(this);
|
const $button = $(this);
|
||||||
$button.prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i> 更新中...');
|
$button.prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i> 更新中...');
|
||||||
await manualUpdateLogic();
|
await manualUpdateLogic();
|
||||||
@@ -217,7 +217,7 @@ function bindCharCardViewerPopupEvents($popup) {
|
|||||||
$popup.find(`#cwb-char-content-${targetUid}`).addClass('active');
|
$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();
|
e.stopPropagation();
|
||||||
if (confirm('您确定要删除这个角色条目吗?此操作不可撤销。')) {
|
if (confirm('您确定要删除这个角色条目吗?此操作不可撤销。')) {
|
||||||
const uidToDelete = $(this).data('char-uid');
|
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('您确定要清除当前聊天中的所有角色卡和总览吗?此操作将删除所有相关条目,且不可撤销。')) {
|
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');
|
return $(this).data('char-uid');
|
||||||
}).get();
|
}).get();
|
||||||
if (allUids.length > 0) {
|
if (allUids.length > 0) {
|
||||||
@@ -278,10 +278,18 @@ function bindCharCardViewerPopupEvents($popup) {
|
|||||||
if ($field.data('is-array')) {
|
if ($field.data('is-array')) {
|
||||||
value = value.split('\n').map(l => l.trim()).filter(Boolean);
|
value = value.split('\n').map(l => l.trim()).filter(Boolean);
|
||||||
}
|
}
|
||||||
if(path){
|
if (path) {
|
||||||
setNestedValue(collectedData, path, value);
|
setNestedValue(collectedData, path, value);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
let localTavernHelper = TavernHelper;
|
||||||
|
if (!localTavernHelper) {
|
||||||
|
// TavernHelper 未定义的情况下触发,但是为什么?
|
||||||
|
(localTavernHelper = window.TavernHelper);
|
||||||
|
if (localTavernHelper) {
|
||||||
|
TavernHelper = localTavernHelper;
|
||||||
|
}
|
||||||
|
}
|
||||||
const finalContentToSave = buildCustomFormat(collectedData);
|
const finalContentToSave = buildCustomFormat(collectedData);
|
||||||
const allEntries = await TavernHelper.getLorebookEntries(book);
|
const allEntries = await TavernHelper.getLorebookEntries(book);
|
||||||
const entryToUpdate = allEntries.find(e => e.uid === targetUid);
|
const entryToUpdate = allEntries.find(e => e.uid === targetUid);
|
||||||
@@ -326,7 +334,14 @@ function bindCharCardViewerPopupEvents($popup) {
|
|||||||
order: finalEntryData.order,
|
order: finalEntryData.order,
|
||||||
hasDepthField: 'depth' in finalEntryData
|
hasDepthField: 'depth' in finalEntryData
|
||||||
});
|
});
|
||||||
|
localTavernHelper = TavernHelper;
|
||||||
|
if (!localTavernHelper) {
|
||||||
|
// TavernHelper 未定义的情况下触发,但是为什么?
|
||||||
|
(localTavernHelper = window.TavernHelper);
|
||||||
|
if (localTavernHelper) {
|
||||||
|
TavernHelper = localTavernHelper;
|
||||||
|
}
|
||||||
|
}
|
||||||
await TavernHelper.setLorebookEntries(book, [finalEntryData]);
|
await TavernHelper.setLorebookEntries(book, [finalEntryData]);
|
||||||
showToastr('success', '角色卡已成功保存!');
|
showToastr('success', '角色卡已成功保存!');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -353,6 +368,14 @@ export async function showCharCardViewerPopup() {
|
|||||||
bindCharCardViewerPopupEvents($(`#${CHAR_CARD_VIEWER_POPUP_ID}`));
|
bindCharCardViewerPopupEvents($(`#${CHAR_CARD_VIEWER_POPUP_ID}`));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let localTavernHelper = TavernHelper;
|
||||||
|
if (!localTavernHelper) {
|
||||||
|
// TavernHelper 未定义的情况下触发,但是为什么?
|
||||||
|
(localTavernHelper = window.TavernHelper);
|
||||||
|
if (localTavernHelper) {
|
||||||
|
TavernHelper = localTavernHelper;
|
||||||
|
}
|
||||||
|
}
|
||||||
const allEntries = await TavernHelper.getLorebookEntries(book);
|
const allEntries = await TavernHelper.getLorebookEntries(book);
|
||||||
let currentChatId = state.currentChatFileIdentifier;
|
let currentChatId = state.currentChatFileIdentifier;
|
||||||
|
|
||||||
@@ -618,39 +641,39 @@ export function updateViewerButtonVisibility() {
|
|||||||
export function bindCwbApiEvents() {
|
export function bindCwbApiEvents() {
|
||||||
console.log('[CWB] Binding API events');
|
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();
|
const value = $(this).val();
|
||||||
extension_settings[extensionName].cwb_api_url = value;
|
extension_settings[extensionName].cwb_api_url = value;
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#cwb-api-key').off('input').on('input', function() {
|
$('#cwb-api-key').off('input').on('input', function () {
|
||||||
const value = $(this).val();
|
const value = $(this).val();
|
||||||
extension_settings[extensionName].cwb_api_key = value;
|
extension_settings[extensionName].cwb_api_key = value;
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#cwb-model').off('input').on('input', function() {
|
$('#cwb-model').off('input').on('input', function () {
|
||||||
const value = $(this).val();
|
const value = $(this).val();
|
||||||
extension_settings[extensionName].cwb_model = value;
|
extension_settings[extensionName].cwb_model = value;
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#cwb-temperature').off('input').on('input', function() {
|
$('#cwb-temperature').off('input').on('input', function () {
|
||||||
const value = parseFloat($(this).val());
|
const value = parseFloat($(this).val());
|
||||||
$('#cwb-temperature-value').text(value);
|
$('#cwb-temperature-value').text(value);
|
||||||
extension_settings[extensionName].cwb_temperature = value;
|
extension_settings[extensionName].cwb_temperature = value;
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#cwb-max-tokens').off('input').on('input', function() {
|
$('#cwb-max-tokens').off('input').on('input', function () {
|
||||||
const value = parseInt($(this).val());
|
const value = parseInt($(this).val());
|
||||||
$('#cwb-max-tokens-value').text(value);
|
$('#cwb-max-tokens-value').text(value);
|
||||||
extension_settings[extensionName].cwb_max_tokens = value;
|
extension_settings[extensionName].cwb_max_tokens = value;
|
||||||
saveSettingsDebounced();
|
saveSettingsDebounced();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#cwb-test-connection').off('click').on('click', async function() {
|
$('#cwb-test-connection').off('click').on('click', async function () {
|
||||||
const $button = $(this);
|
const $button = $(this);
|
||||||
$button.prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i> 测试中...');
|
$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);
|
const $button = $(this);
|
||||||
$button.prop('disabled', true).html('<i class="fas fa-spinner fa-spin"></i> 获取中...');
|
$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