mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge pull request #1800 from EX3-0/patch-1
Update openai.js added /proxy command.
This commit is contained in:
@ -31,6 +31,7 @@ import {
|
|||||||
this_chid,
|
this_chid,
|
||||||
} from '../script.js';
|
} from '../script.js';
|
||||||
import { groups, selected_group } from './group-chats.js';
|
import { groups, selected_group } from './group-chats.js';
|
||||||
|
import { registerSlashCommand } from './slash-commands.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
chatCompletionDefaultPrompts,
|
chatCompletionDefaultPrompts,
|
||||||
@ -3934,6 +3935,28 @@ $('#delete_proxy').on('click', async function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function runProxyCallback(_, value) {
|
||||||
|
if (!value) {
|
||||||
|
toastr.warning('Proxy preset name is required');
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const proxyNames = proxies.map(preset => preset.name);
|
||||||
|
const fuse = new Fuse(proxyNames);
|
||||||
|
const result = fuse.search(value);
|
||||||
|
|
||||||
|
if (result.length === 0) {
|
||||||
|
toastr.warning(`Proxy preset "${value}" not found`);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
const foundName = result[0].item;
|
||||||
|
$('#openai_proxy_preset').val(foundName).trigger('change');
|
||||||
|
return foundName;
|
||||||
|
}
|
||||||
|
|
||||||
|
registerSlashCommand('proxy', runProxyCallback, [], '<span class="monospace">(name)</span> – sets a proxy preset by name');
|
||||||
|
|
||||||
$(document).ready(async function () {
|
$(document).ready(async function () {
|
||||||
$('#test_api_button').on('click', testApiConnection);
|
$('#test_api_button').on('click', testApiConnection);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user