mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2024-12-11 17:07:07 +01:00
Set api-url with connection-manager
This commit is contained in:
parent
f4da527d95
commit
e77f5a1c93
@ -14,6 +14,7 @@ const DEFAULT_SETTINGS = {
|
||||
const COMMON_COMMANDS = [
|
||||
'api',
|
||||
'preset',
|
||||
'api-url',
|
||||
'model',
|
||||
];
|
||||
|
||||
@ -32,6 +33,7 @@ const TC_COMMANDS = [
|
||||
|
||||
const FANCY_NAMES = {
|
||||
'api': 'API',
|
||||
'api-url': 'Server URL',
|
||||
'preset': 'Settings Preset',
|
||||
'model': 'Model',
|
||||
'proxy': 'Proxy Preset',
|
||||
@ -57,6 +59,8 @@ const FANCY_NAMES = {
|
||||
*/
|
||||
|
||||
const escapeArgument = (a) => a.replace(/"/g, '\\"').replace(/\|/g, '\\|');
|
||||
const collapseSpaces = (s) => s.replace(/\s+/g, ' ').trim();
|
||||
const makeUnique = (s, f, i) => { if (!f(s)) { return s; } else { while (f(`${s} (${i})`)) { i++; } return `${s} (${i})`; } };
|
||||
|
||||
/**
|
||||
* Reads the connection profile from the commands.
|
||||
@ -107,7 +111,8 @@ async function createConnectionProfile() {
|
||||
|
||||
const profileForDisplay = makeFancyProfile(profile);
|
||||
const template = await renderExtensionTemplateAsync(MODULE_NAME, 'profile', { profile: profileForDisplay });
|
||||
const suggestedName = `${profile.api} ${profile.model} - ${profile.preset}`;
|
||||
const checkName = (n) => extension_settings.connectionManager.profiles.some(p => p.name === n);
|
||||
const suggestedName = makeUnique(collapseSpaces(`${profile.api ?? ''} ${profile.model ?? ''} - ${profile.preset ?? ''}`), checkName, 1);
|
||||
const name = await callGenericPopup(template, POPUP_TYPE.INPUT, suggestedName, { rows: 2 });
|
||||
|
||||
if (!name) {
|
||||
|
Loading…
Reference in New Issue
Block a user