mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'staging' into slash-command-enums
This commit is contained in:
@ -81,12 +81,15 @@ dialog {
|
|||||||
animation: fade-out var(--animation-duration-slow) ease-in-out;
|
animation: fade-out var(--animation-duration-slow) ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fix toastr in dialogs by actually placing it at the top of the screen via transform */
|
|
||||||
.popup #toast-container {
|
.popup #toast-container {
|
||||||
|
/* Fix toastr in dialogs by actually placing it at the top of the screen via transform */
|
||||||
height: 100svh;
|
height: 100svh;
|
||||||
top: calc(50% + var(--topBarBlockSize));
|
top: calc(50% + var(--topBarBlockSize));
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
|
|
||||||
|
/* Fix text align, popups are centered by default. toasts should not. */
|
||||||
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.popup-input {
|
.popup-input {
|
||||||
|
@ -5497,7 +5497,6 @@
|
|||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div id="logit_bias_template" class="template_element">
|
<div id="logit_bias_template" class="template_element">
|
||||||
<div class="logit_bias_form">
|
<div class="logit_bias_form">
|
||||||
<input class="logit_bias_text text_pole" data-i18n="[placeholder]Type here..." placeholder="type here..." />
|
<input class="logit_bias_text text_pole" data-i18n="[placeholder]Type here..." placeholder="type here..." />
|
||||||
|
@ -433,7 +433,9 @@ export const event_types = {
|
|||||||
CHARACTER_MESSAGE_RENDERED: 'character_message_rendered',
|
CHARACTER_MESSAGE_RENDERED: 'character_message_rendered',
|
||||||
FORCE_SET_BACKGROUND: 'force_set_background',
|
FORCE_SET_BACKGROUND: 'force_set_background',
|
||||||
CHAT_DELETED: 'chat_deleted',
|
CHAT_DELETED: 'chat_deleted',
|
||||||
|
CHAT_CREATED: 'chat_created',
|
||||||
GROUP_CHAT_DELETED: 'group_chat_deleted',
|
GROUP_CHAT_DELETED: 'group_chat_deleted',
|
||||||
|
GROUP_CHAT_CREATED: 'group_chat_created',
|
||||||
GENERATE_BEFORE_COMBINE_PROMPTS: 'generate_before_combine_prompts',
|
GENERATE_BEFORE_COMBINE_PROMPTS: 'generate_before_combine_prompts',
|
||||||
GENERATE_AFTER_COMBINE_PROMPTS: 'generate_after_combine_prompts',
|
GENERATE_AFTER_COMBINE_PROMPTS: 'generate_after_combine_prompts',
|
||||||
GROUP_MEMBER_DRAFTED: 'group_member_drafted',
|
GROUP_MEMBER_DRAFTED: 'group_member_drafted',
|
||||||
@ -5890,11 +5892,13 @@ export async function getChat() {
|
|||||||
|
|
||||||
async function getChatResult() {
|
async function getChatResult() {
|
||||||
name2 = characters[this_chid].name;
|
name2 = characters[this_chid].name;
|
||||||
|
let freshChat = false;
|
||||||
if (chat.length === 0) {
|
if (chat.length === 0) {
|
||||||
const message = getFirstMessage();
|
const message = getFirstMessage();
|
||||||
if (message.mes) {
|
if (message.mes) {
|
||||||
chat.push(message);
|
chat.push(message);
|
||||||
await saveChatConditional();
|
await saveChatConditional();
|
||||||
|
freshChat = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await loadItemizedPrompts(getCurrentChatId());
|
await loadItemizedPrompts(getCurrentChatId());
|
||||||
@ -5902,6 +5906,7 @@ async function getChatResult() {
|
|||||||
select_selected_character(this_chid);
|
select_selected_character(this_chid);
|
||||||
|
|
||||||
await eventSource.emit(event_types.CHAT_CHANGED, (getCurrentChatId()));
|
await eventSource.emit(event_types.CHAT_CHANGED, (getCurrentChatId()));
|
||||||
|
if (freshChat) await eventSource.emit(event_types.CHAT_CREATED);
|
||||||
|
|
||||||
if (chat.length === 1) {
|
if (chat.length === 1) {
|
||||||
const chat_id = (chat.length - 1);
|
const chat_id = (chat.length - 1);
|
||||||
|
@ -39,6 +39,7 @@ import { textgen_types, textgenerationwebui_settings as textgen_settings, getTex
|
|||||||
import { debounce_timeout } from './constants.js';
|
import { debounce_timeout } from './constants.js';
|
||||||
|
|
||||||
import Bowser from '../lib/bowser.min.js';
|
import Bowser from '../lib/bowser.min.js';
|
||||||
|
import { Popup } from './popup.js';
|
||||||
|
|
||||||
var RPanelPin = document.getElementById('rm_button_panel_pin');
|
var RPanelPin = document.getElementById('rm_button_panel_pin');
|
||||||
var LPanelPin = document.getElementById('lm_button_panel_pin');
|
var LPanelPin = document.getElementById('lm_button_panel_pin');
|
||||||
@ -1096,6 +1097,9 @@ export function initRossMods() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (event.key == 'Escape') { //closes various panels
|
if (event.key == 'Escape') { //closes various panels
|
||||||
|
// Do not close panels if we are currently inside a popup
|
||||||
|
if (Popup.util.isPopupOpen())
|
||||||
|
return;
|
||||||
|
|
||||||
//dont override Escape hotkey functions from script.js
|
//dont override Escape hotkey functions from script.js
|
||||||
//"close edit box" and "cancel stream generation".
|
//"close edit box" and "cancel stream generation".
|
||||||
|
@ -183,6 +183,7 @@ export async function getGroupChat(groupId, reload = false) {
|
|||||||
const group = groups.find((x) => x.id === groupId);
|
const group = groups.find((x) => x.id === groupId);
|
||||||
const chat_id = group.chat_id;
|
const chat_id = group.chat_id;
|
||||||
const data = await loadGroupChat(chat_id);
|
const data = await loadGroupChat(chat_id);
|
||||||
|
let freshChat = false;
|
||||||
|
|
||||||
await loadItemizedPrompts(getCurrentChatId());
|
await loadItemizedPrompts(getCurrentChatId());
|
||||||
|
|
||||||
@ -216,6 +217,7 @@ export async function getGroupChat(groupId, reload = false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
await saveGroupChat(groupId, false);
|
await saveGroupChat(groupId, false);
|
||||||
|
freshChat = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (group) {
|
if (group) {
|
||||||
@ -228,6 +230,7 @@ export async function getGroupChat(groupId, reload = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await eventSource.emit(event_types.CHAT_CHANGED, getCurrentChatId());
|
await eventSource.emit(event_types.CHAT_CHANGED, getCurrentChatId());
|
||||||
|
if (freshChat) await eventSource.emit(event_types.GROUP_CHAT_CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -195,19 +195,19 @@ export class Popup {
|
|||||||
|
|
||||||
this.ok.addEventListener('click', () => this.complete(POPUP_RESULT.AFFIRMATIVE));
|
this.ok.addEventListener('click', () => this.complete(POPUP_RESULT.AFFIRMATIVE));
|
||||||
this.cancel.addEventListener('click', () => this.complete(POPUP_RESULT.NEGATIVE));
|
this.cancel.addEventListener('click', () => this.complete(POPUP_RESULT.NEGATIVE));
|
||||||
|
|
||||||
|
// Bind dialog listeners manually, so we can be sure context is preserved
|
||||||
|
const cancelListener = (evt) => {
|
||||||
|
this.complete(POPUP_RESULT.CANCELLED);
|
||||||
|
evt.preventDefault();
|
||||||
|
evt.stopPropagation();
|
||||||
|
window.removeEventListener('cancel', cancelListenerBound);
|
||||||
|
};
|
||||||
|
const cancelListenerBound = cancelListener.bind(this);
|
||||||
|
this.dlg.addEventListener('cancel', cancelListenerBound);
|
||||||
|
|
||||||
const keyListener = (evt) => {
|
const keyListener = (evt) => {
|
||||||
switch (evt.key) {
|
switch (evt.key) {
|
||||||
case 'Escape': {
|
|
||||||
// Check if we are the currently active popup
|
|
||||||
if (this.dlg != document.activeElement?.closest('.popup'))
|
|
||||||
return;
|
|
||||||
|
|
||||||
this.complete(POPUP_RESULT.CANCELLED);
|
|
||||||
evt.preventDefault();
|
|
||||||
evt.stopPropagation();
|
|
||||||
window.removeEventListener('keydown', keyListenerBound);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'Enter': {
|
case 'Enter': {
|
||||||
// CTRL+Enter counts as a closing action, but all other modifiers (ALT, SHIFT) should not trigger this
|
// CTRL+Enter counts as a closing action, but all other modifiers (ALT, SHIFT) should not trigger this
|
||||||
if (evt.altKey || evt.shiftKey)
|
if (evt.altKey || evt.shiftKey)
|
||||||
|
@ -119,7 +119,7 @@ async function sendClaudeRequest(request, response) {
|
|||||||
let use_system_prompt = (request.body.model.startsWith('claude-2') || request.body.model.startsWith('claude-3')) && request.body.claude_use_sysprompt;
|
let use_system_prompt = (request.body.model.startsWith('claude-2') || request.body.model.startsWith('claude-3')) && request.body.claude_use_sysprompt;
|
||||||
let converted_prompt = convertClaudeMessages(request.body.messages, request.body.assistant_prefill, use_system_prompt, request.body.human_sysprompt_message, request.body.char_name, request.body.user_name);
|
let converted_prompt = convertClaudeMessages(request.body.messages, request.body.assistant_prefill, use_system_prompt, request.body.human_sysprompt_message, request.body.char_name, request.body.user_name);
|
||||||
// Add custom stop sequences
|
// Add custom stop sequences
|
||||||
const stopSequences = ['\n\nHuman:', '\n\nSystem:', '\n\nAssistant:'];
|
const stopSequences = [];
|
||||||
if (Array.isArray(request.body.stop)) {
|
if (Array.isArray(request.body.stop)) {
|
||||||
stopSequences.push(...request.body.stop);
|
stopSequences.push(...request.body.stop);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ router.post('/serpapi', jsonParser, async (request, response) => {
|
|||||||
const { query } = request.body;
|
const { query } = request.body;
|
||||||
const result = await fetch(`https://serpapi.com/search.json?q=${encodeURIComponent(query)}&api_key=${key}`);
|
const result = await fetch(`https://serpapi.com/search.json?q=${encodeURIComponent(query)}&api_key=${key}`);
|
||||||
|
|
||||||
|
console.log('SerpApi query', query);
|
||||||
|
|
||||||
if (!result.ok) {
|
if (!result.ok) {
|
||||||
const text = await result.text();
|
const text = await result.text();
|
||||||
console.log('SerpApi request failed', result.statusText, text);
|
console.log('SerpApi request failed', result.statusText, text);
|
||||||
@ -143,6 +145,8 @@ router.post('/searxng', jsonParser, async (request, response) => {
|
|||||||
return response.sendStatus(400);
|
return response.sendStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('SearXNG query', baseUrl, query);
|
||||||
|
|
||||||
const url = new URL(baseUrl);
|
const url = new URL(baseUrl);
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
params.append('q', query);
|
params.append('q', query);
|
||||||
@ -205,6 +209,8 @@ router.post('/visit', jsonParser, async (request, response) => {
|
|||||||
return response.sendStatus(400);
|
return response.sendStatus(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('Visiting web URL', url);
|
||||||
|
|
||||||
const result = await fetch(url, { headers: visitHeaders });
|
const result = await fetch(url, { headers: visitHeaders });
|
||||||
|
|
||||||
if (!result.ok) {
|
if (!result.ok) {
|
||||||
|
Reference in New Issue
Block a user