Merge branch 'SillyTavern:staging' into staging

This commit is contained in:
Tony Ribeiro
2023-10-17 20:18:29 +02:00
committed by GitHub
46 changed files with 349 additions and 4591 deletions

View File

@@ -288,7 +288,8 @@ function registerEndpoints(app, jsonParser) {
if (!req.body) return res.sendStatus(400);
let num_tokens = 0;
const model = getTokenizerModel(String(req.query.model || ''));
const queryModel = String(req.query.model || '');
const model = getTokenizerModel(queryModel);
if (model == 'claude') {
num_tokens = countClaudeTokens(claude_tokenizer, req.body);
@@ -316,6 +317,12 @@ function registerEndpoints(app, jsonParser) {
}
num_tokens += tokensPadding;
// NB: Since 2023-10-14, the GPT-3.5 Turbo 0301 model shoves in 7-9 extra tokens to every message.
// More details: https://community.openai.com/t/gpt-3-5-turbo-0301-showing-different-behavior-suddenly/431326/14
if (queryModel.endsWith('-0301')) {
num_tokens += 9;
}
// not needed for cached tokenizers
//tokenizer.free();