Merge branch 'staging' into slash-command-enums

This commit is contained in:
Wolfsblvt 2024-06-21 20:07:19 +02:00
commit 3ab5cc1766
8 changed files with 34 additions and 14 deletions

View File

@ -81,12 +81,15 @@ dialog {
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 {
/* Fix toastr in dialogs by actually placing it at the top of the screen via transform */
height: 100svh;
top: calc(50% + var(--topBarBlockSize));
left: 50%;
transform: translate(-50%, -50%);
/* Fix text align, popups are centered by default. toasts should not. */
text-align: left;
}
.popup-input {

View File

@ -5497,7 +5497,6 @@
</form>
</div>
</div>
</div>
<div id="logit_bias_template" class="template_element">
<div class="logit_bias_form">
<input class="logit_bias_text text_pole" data-i18n="[placeholder]Type here..." placeholder="type here..." />

View File

@ -433,7 +433,9 @@ export const event_types = {
CHARACTER_MESSAGE_RENDERED: 'character_message_rendered',
FORCE_SET_BACKGROUND: 'force_set_background',
CHAT_DELETED: 'chat_deleted',
CHAT_CREATED: 'chat_created',
GROUP_CHAT_DELETED: 'group_chat_deleted',
GROUP_CHAT_CREATED: 'group_chat_created',
GENERATE_BEFORE_COMBINE_PROMPTS: 'generate_before_combine_prompts',
GENERATE_AFTER_COMBINE_PROMPTS: 'generate_after_combine_prompts',
GROUP_MEMBER_DRAFTED: 'group_member_drafted',
@ -5890,11 +5892,13 @@ export async function getChat() {
async function getChatResult() {
name2 = characters[this_chid].name;
let freshChat = false;
if (chat.length === 0) {
const message = getFirstMessage();
if (message.mes) {
chat.push(message);
await saveChatConditional();
freshChat = true;
}
}
await loadItemizedPrompts(getCurrentChatId());
@ -5902,6 +5906,7 @@ async function getChatResult() {
select_selected_character(this_chid);
await eventSource.emit(event_types.CHAT_CHANGED, (getCurrentChatId()));
if (freshChat) await eventSource.emit(event_types.CHAT_CREATED);
if (chat.length === 1) {
const chat_id = (chat.length - 1);

View File

@ -39,6 +39,7 @@ import { textgen_types, textgenerationwebui_settings as textgen_settings, getTex
import { debounce_timeout } from './constants.js';
import Bowser from '../lib/bowser.min.js';
import { Popup } from './popup.js';
var RPanelPin = document.getElementById('rm_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
// Do not close panels if we are currently inside a popup
if (Popup.util.isPopupOpen())
return;
//dont override Escape hotkey functions from script.js
//"close edit box" and "cancel stream generation".

View File

@ -183,6 +183,7 @@ export async function getGroupChat(groupId, reload = false) {
const group = groups.find((x) => x.id === groupId);
const chat_id = group.chat_id;
const data = await loadGroupChat(chat_id);
let freshChat = false;
await loadItemizedPrompts(getCurrentChatId());
@ -216,6 +217,7 @@ export async function getGroupChat(groupId, reload = false) {
}
}
await saveGroupChat(groupId, false);
freshChat = true;
}
if (group) {
@ -228,6 +230,7 @@ export async function getGroupChat(groupId, reload = false) {
}
await eventSource.emit(event_types.CHAT_CHANGED, getCurrentChatId());
if (freshChat) await eventSource.emit(event_types.GROUP_CHAT_CREATED);
}
/**

View File

@ -195,19 +195,19 @@ export class Popup {
this.ok.addEventListener('click', () => this.complete(POPUP_RESULT.AFFIRMATIVE));
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) => {
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': {
// CTRL+Enter counts as a closing action, but all other modifiers (ALT, SHIFT) should not trigger this
if (evt.altKey || evt.shiftKey)

View File

@ -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 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
const stopSequences = ['\n\nHuman:', '\n\nSystem:', '\n\nAssistant:'];
const stopSequences = [];
if (Array.isArray(request.body.stop)) {
stopSequences.push(...request.body.stop);
}

View File

@ -34,6 +34,8 @@ router.post('/serpapi', jsonParser, async (request, response) => {
const { query } = request.body;
const result = await fetch(`https://serpapi.com/search.json?q=${encodeURIComponent(query)}&api_key=${key}`);
console.log('SerpApi query', query);
if (!result.ok) {
const text = await result.text();
console.log('SerpApi request failed', result.statusText, text);
@ -143,6 +145,8 @@ router.post('/searxng', jsonParser, async (request, response) => {
return response.sendStatus(400);
}
console.log('SearXNG query', baseUrl, query);
const url = new URL(baseUrl);
const params = new URLSearchParams();
params.append('q', query);
@ -205,6 +209,8 @@ router.post('/visit', jsonParser, async (request, response) => {
return response.sendStatus(400);
}
console.log('Visiting web URL', url);
const result = await fetch(url, { headers: visitHeaders });
if (!result.ok) {