Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Just a fork for some testing - nothing to see here


# SillyTavern MultiPlayer (STMP)

SillyTavern MultiPlayer is an LLM chat interface that allows multiple users to chat together with one or more AI characters.
Expand Down
34 changes: 19 additions & 15 deletions src/api-calls.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ async function getAPIDefaults(shouldReturn = null) {
TCAPIDefaults = TCAPICallParams;
HordeAPIDefaults = HordeAPICallParams;
if (shouldReturn) {
let defaults = [TCAPIDefaults, HordeAPIDefaults]
return defaults
return [TCAPIDefaults, HordeAPIDefaults];
}

} catch (error) {
logger.error('Error reading or parsing default-API-Parameters.json:', error);
}
Expand All @@ -53,15 +51,18 @@ async function getAPIDefaults(shouldReturn = null) {
// and AIChatUserList but BEFORE sending the network request. Enables single-pass
// streaming setup (initialize listeners early) without a separate dry-run.
async function getAIResponse(isStreaming, hordeKey, engineMode, user, liveConfig, liveAPI, preInitCallback, parsedMessage, shouldContinue) {
// logger.warn('getAIResponse liveAPI:', liveAPI)
// logger.warn(`liveConfig: ${JSON.stringify(liveConfig)}`);
const isCCSelected = liveAPI.type === 'CC';
const isClaude = liveAPI.claude;

let apiCallParams;

try {
apiCallParams = engineMode === 'TC' ? TCAPIDefaults : HordeAPIDefaults;
if (!TCAPIDefaults || !HordeAPIDefaults) {
await getAPIDefaults();
}
let apiCallParams = engineMode === 'TC' ? TCAPIDefaults : HordeAPIDefaults;

if (!apiCallParams && !isCCSelected) {
throw new Error("API Default Parameters could not be loaded.");
}

const charFile = liveConfig.promptConfig.selectedCharacter;
const cardData = await fio.charaRead(charFile, 'png');
Expand Down Expand Up @@ -137,9 +138,9 @@ async function getAIResponse(isStreaming, hordeKey, engineMode, user, liveConfig
apiCallParams.max_tokens = Number(liveConfig.promptConfig.responseLength);
}

}
}



const [finalApiCallParams, entitiesList] = await setStopStrings(liveConfig, apiCallParams, includedChatObjects, liveAPI);

// Pre-stream initializer (if provided)
Expand Down Expand Up @@ -353,7 +354,7 @@ async function setStopStrings(liveConfig, APICallParams, includedChatObjects, li
//logger.info(APICallParams)
//logger.info(targetObj)
// logger.debug(liveAPI)
// logger.debug(liveConfig)
// logger.debug(liveConfig)
if (liveAPI.claude === (1 || true)) { //for claude
//logger.info('setting Claude stop strings')
APICallParams.stop_sequences = targetObj
Expand All @@ -374,12 +375,15 @@ async function setStopStrings(liveConfig, APICallParams, includedChatObjects, li
//MARK: replaceMacros
function replaceMacros(string, username = null, charname = null) {
//logger.debug(username, charname)
var replacedString = string
if (typeof string !== 'string') {
return '';
}
var replacedString = string;
if (username !== null && charname !== null) {
replacedString = replacedString.replace(/{{user}}/g, username);
replacedString = replacedString.replace(/{{char}}/g, charname);
replacedString = replacedString.replace(/{{user}}/g, username);
replacedString = replacedString.replace(/{{char}}/g, charname);
}
return replacedString
return replacedString;
}

function collapseNewlines(x) {
Expand Down
12 changes: 8 additions & 4 deletions src/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,14 @@ const createTextListener = async (parsedMessage, liveConfig, AIChatUserList, use

const isPrefillDisabled = liveConfig.promptConfig.killResponsePrefill === true;

if (!isPrefillDisabled && !haveInsertedPrefillForDisplayYet && !shouldContinue && liveConfig.promptConfig.responsePrefill.length > 0) {
//logger.error('TEXTLISTENER: inserting prefill for display:', liveConfig.promptConfig.responsePrefill)
//this just adds the prefill into the displayed output.
accumulatedStreamOutput += liveConfig.promptConfig.responsePrefill;
if (!isPrefillDisabled && !haveInsertedPrefillForDisplayYet && !shouldContinue &&
// (liveConfig?.promptConfig?.responsePrefill ?? []) forces array
(Array.isArray(liveConfig?.promptConfig?.responsePrefill) ?
liveConfig.promptConfig.responsePrefill :
[]).length > 0
) {
// Add the prefill value to the output string.
accumulatedStreamOutput += String(liveConfig?.promptConfig?.responsePrefill ?? []);
haveInsertedPrefillForDisplayYet = true;
}

Expand Down