mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
New oobabooga code https://github.com/oobabooga/text-generation-webui/pull/990
This commit is contained in:
@ -29,9 +29,9 @@ let textgenerationwebui_settings = {
|
||||
stopping_strings: [],
|
||||
truncation_length: 2048,
|
||||
ban_eos_token: false,
|
||||
streaming: false,
|
||||
fn_index: 43,
|
||||
skip_special_tokens: true,
|
||||
streaming: false,
|
||||
streaming_url: 'ws://127.0.0.1:5005/api/v1/stream',
|
||||
};
|
||||
|
||||
let textgenerationwebui_presets = [];
|
||||
@ -54,8 +54,9 @@ const setting_names = [
|
||||
"seed",
|
||||
"add_bos_token",
|
||||
"ban_eos_token",
|
||||
"fn_index",
|
||||
"skip_special_tokens",
|
||||
"streaming",
|
||||
"streaming_url",
|
||||
];
|
||||
|
||||
function selectPreset(name) {
|
||||
@ -109,12 +110,17 @@ $(document).ready(function () {
|
||||
$(`#${i}_textgenerationwebui`).attr("x-setting-id", i);
|
||||
$(document).on("input", `#${i}_textgenerationwebui`, function () {
|
||||
const isCheckbox = $(this).attr('type') == 'checkbox';
|
||||
const isText = $(this).attr('type') == 'text';
|
||||
const id = $(this).attr("x-setting-id");
|
||||
|
||||
if (isCheckbox) {
|
||||
const value = $(this).prop('checked');
|
||||
textgenerationwebui_settings[id] = value;
|
||||
}
|
||||
else if (isText) {
|
||||
const value = $(this).val();
|
||||
textgenerationwebui_settings[id] = value;
|
||||
}
|
||||
else {
|
||||
const value = parseFloat($(this).val());
|
||||
$(`#${id}_counter_textgenerationwebui`).text(value.toFixed(2));
|
||||
@ -132,10 +138,14 @@ function setSettingByName(i, value, trigger) {
|
||||
}
|
||||
|
||||
const isCheckbox = $(`#${i}_textgenerationwebui`).attr('type') == 'checkbox';
|
||||
const isText = $(`#${i}_textgenerationwebui`).attr('type') == 'text';
|
||||
if (isCheckbox) {
|
||||
const val = Boolean(value);
|
||||
$(`#${i}_textgenerationwebui`).prop('checked', val);
|
||||
}
|
||||
else if (isText) {
|
||||
$(`#${i}_textgenerationwebui`).val(value);
|
||||
}
|
||||
else {
|
||||
const val = parseFloat(value);
|
||||
$(`#${i}_textgenerationwebui`).val(val);
|
||||
@ -150,10 +160,10 @@ function setSettingByName(i, value, trigger) {
|
||||
async function generateTextGenWithStreaming(generate_data, signal) {
|
||||
const response = await fetch('/generate_textgenerationwebui', {
|
||||
headers: {
|
||||
'X-CSRF-Token': token,
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-Token': token,
|
||||
'X-Response-Streaming': true,
|
||||
'X-Gradio-Streaming-Function': textgenerationwebui_settings.fn_index,
|
||||
'X-Streaming-URL': textgenerationwebui_settings.streaming_url,
|
||||
},
|
||||
body: JSON.stringify(generate_data),
|
||||
method: 'POST',
|
||||
@ -167,22 +177,7 @@ async function generateTextGenWithStreaming(generate_data, signal) {
|
||||
while (true) {
|
||||
const { done, value } = await reader.read();
|
||||
let response = decoder.decode(value);
|
||||
let delta = '';
|
||||
|
||||
try {
|
||||
delta = response.split('\n').map(x => {
|
||||
try {
|
||||
return JSON.parse(x).delta;
|
||||
} catch {
|
||||
return '';
|
||||
}
|
||||
}).join('');
|
||||
}
|
||||
catch {
|
||||
delta = '';
|
||||
}
|
||||
|
||||
getMessage += delta;
|
||||
getMessage += response;
|
||||
|
||||
if (done) {
|
||||
return;
|
||||
|
Reference in New Issue
Block a user