Merge pull request #1800 from EX3-0/patch-1
Update openai.js added /proxy command.
This commit is contained in:
commit
d7f86a7f6b
|
@ -31,6 +31,7 @@ import {
|
|||
this_chid,
|
||||
} from '../script.js';
|
||||
import { groups, selected_group } from './group-chats.js';
|
||||
import { registerSlashCommand } from './slash-commands.js';
|
||||
|
||||
import {
|
||||
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 () {
|
||||
$('#test_api_button').on('click', testApiConnection);
|
||||
|
||||
|
|
Loading…
Reference in New Issue