mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-13 18:40:11 +01:00
Merge pull request #3554 from bmen25124/new_exports
Exported getTextGenServer, extractMessageFromData methods. added opti…
This commit is contained in:
commit
20a982491a
@ -5708,14 +5708,15 @@ function parseAndSaveLogprobs(data, continueFrom) {
|
||||
/**
|
||||
* Extracts the message from the response data.
|
||||
* @param {object} data Response data
|
||||
* @param {string} activeApi If it's set, ignores active API
|
||||
* @returns {string} Extracted message
|
||||
*/
|
||||
function extractMessageFromData(data) {
|
||||
export function extractMessageFromData(data, activeApi = null) {
|
||||
if (typeof data === 'string') {
|
||||
return data;
|
||||
}
|
||||
|
||||
switch (main_api) {
|
||||
switch (activeApi ?? main_api) {
|
||||
case 'kobold':
|
||||
return data.results[0].text;
|
||||
case 'koboldhorde':
|
||||
@ -8873,7 +8874,7 @@ const swipe_right = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const CONNECT_API_MAP = {
|
||||
export const CONNECT_API_MAP = {
|
||||
// Default APIs not contined inside text gen / chat gen
|
||||
'kobold': {
|
||||
selected: 'kobold',
|
||||
|
@ -6,11 +6,13 @@ import {
|
||||
characters,
|
||||
chat,
|
||||
chat_metadata,
|
||||
CONNECT_API_MAP,
|
||||
create_save,
|
||||
deactivateSendButtons,
|
||||
event_types,
|
||||
eventSource,
|
||||
extension_prompts,
|
||||
extractMessageFromData,
|
||||
Generate,
|
||||
generateQuietPrompt,
|
||||
getCharacters,
|
||||
@ -58,6 +60,7 @@ import { MacrosParser } from './macros.js';
|
||||
import { oai_settings } from './openai.js';
|
||||
import { callGenericPopup, Popup, POPUP_RESULT, POPUP_TYPE } from './popup.js';
|
||||
import { power_user, registerDebugFunction } from './power-user.js';
|
||||
import { getPresetManager } from './preset-manager.js';
|
||||
import { humanizedDateTime, isMobile, shouldSendOnEnter } from './RossAscends-mods.js';
|
||||
import { ScraperManager } from './scrapers.js';
|
||||
import { executeSlashCommands, executeSlashCommandsWithOptions, registerSlashCommand } from './slash-commands.js';
|
||||
@ -65,7 +68,7 @@ import { SlashCommand } from './slash-commands/SlashCommand.js';
|
||||
import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js';
|
||||
import { SlashCommandParser } from './slash-commands/SlashCommandParser.js';
|
||||
import { tag_map, tags } from './tags.js';
|
||||
import { textgenerationwebui_settings } from './textgen-settings.js';
|
||||
import { getTextGenServer, textgenerationwebui_settings } from './textgen-settings.js';
|
||||
import { tokenizers, getTextTokens, getTokenCount, getTokenCountAsync, getTokenizerModel } from './tokenizers.js';
|
||||
import { ToolManager } from './tool-calling.js';
|
||||
import { accountStorage } from './util/AccountStorage.js';
|
||||
@ -193,6 +196,10 @@ export function getContext() {
|
||||
saveWorldInfo,
|
||||
updateWorldInfoList,
|
||||
convertCharacterBook,
|
||||
CONNECT_API_MAP,
|
||||
getTextGenServer,
|
||||
extractMessageFromData,
|
||||
getPresetManager,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -318,8 +318,14 @@ export function validateTextGenUrl() {
|
||||
control.val(formattedUrl);
|
||||
}
|
||||
|
||||
export function getTextGenServer() {
|
||||
switch (settings.type) {
|
||||
/**
|
||||
* Gets the API URL for the selected text generation type.
|
||||
* @param {string} type If it's set, ignores active type
|
||||
* @returns {string} API URL
|
||||
*/
|
||||
export function getTextGenServer(type = null) {
|
||||
const selectedType = type ?? settings.type;
|
||||
switch (selectedType) {
|
||||
case FEATHERLESS:
|
||||
return FEATHERLESS_SERVER;
|
||||
case MANCER:
|
||||
@ -333,7 +339,7 @@ export function getTextGenServer() {
|
||||
case OPENROUTER:
|
||||
return OPENROUTER_SERVER;
|
||||
default:
|
||||
return settings.server_urls[settings.type] ?? '';
|
||||
return settings.server_urls[selectedType] ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1215,8 +1221,14 @@ function isDynamicTemperatureSupported() {
|
||||
return settings.dynatemp && DYNATEMP_BLOCK?.dataset?.tgType?.includes(settings.type);
|
||||
}
|
||||
|
||||
function getLogprobsNumber() {
|
||||
if (settings.type === VLLM || settings.type === INFERMATICAI) {
|
||||
/**
|
||||
* Gets the number of logprobs to request based on the selected type.
|
||||
* @param {string} type If it's set, ignores active type
|
||||
* @returns {number} Number of logprobs to request
|
||||
*/
|
||||
export function getLogprobsNumber(type = null) {
|
||||
const selectedType = type ?? settings.type;
|
||||
if (selectedType === VLLM || selectedType === INFERMATICAI) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
@ -1228,7 +1240,7 @@ function getLogprobsNumber() {
|
||||
* @param {string} str Input string
|
||||
* @returns {string} Output string
|
||||
*/
|
||||
function replaceMacrosInList(str) {
|
||||
export function replaceMacrosInList(str) {
|
||||
if (!str || typeof str !== 'string') {
|
||||
return str;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user