Fix missing model name in tokenize requests for llama.cpp (fixes #4962) (#5344) * Fix missing model name in tokenize requests for llama.cpp (fixes #4962) The new router mode of llama.cpp allows to switch models on the fly, what is already supported by SillyTavern. The call to the `/tokenize` endpoint did not contain the model name, and failed in router mode. This patch adds the `model` parameter similar to the implementation for other backends. * fix: migrate vllm and aphrodite to new payload field --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>

d306194c5171a6885ec1cb615ab266c89d054f56

allo- <allo@laxu.de>

Signed
2 files changed, +5 -7Ignore whitespace
public/scripts/tokenizers.js+1 -2
@@ -954,8 +954,7 @@ function getTextgenAPITokenizationParams(str) {
954 text: str,954 text: str,
955 api_type: textgen_settings.type,955 api_type: textgen_settings.type,
956 url: getTextGenServer(),956 url: getTextGenServer(),
957 vllm_model: textgen_settings.vllm_model,957 model: getTextGenModel(),
958 aphrodite_model: textgen_settings.aphrodite_model,
959 };958 };
960}959}
961960
src/endpoints/tokenizers.js+4 -5
@@ -1077,8 +1077,7 @@ router.post('/remote/textgenerationwebui/encode', async function (request, respo
1077 }1077 }
1078 const text = String(request.body.text) || '';1078 const text = String(request.body.text) || '';
1079 const baseUrl = String(request.body.url);1079 const baseUrl = String(request.body.url);
1080 const vllmModel = String(request.body.vllm_model) || '';1080 const model = String(request.body.model) || '';
1081 const aphroditeModel = String(request.body.aphrodite_model) || '';
10821081
1083 try {1082 try {
1084 const args = {1083 const args = {
@@ -1102,15 +1101,15 @@ router.post('/remote/textgenerationwebui/encode', async function (request, respo
1102 break;1101 break;
1103 case TEXTGEN_TYPES.LLAMACPP:1102 case TEXTGEN_TYPES.LLAMACPP:
1104 url += '/tokenize';1103 url += '/tokenize';
1105 args.body = JSON.stringify({ 'content': text });1104 args.body = JSON.stringify({ 'model': model, 'content': text });
1106 break;1105 break;
1107 case TEXTGEN_TYPES.VLLM:1106 case TEXTGEN_TYPES.VLLM:
1108 url += '/tokenize';1107 url += '/tokenize';
1109 args.body = JSON.stringify({ 'model': vllmModel, 'prompt': text });1108 args.body = JSON.stringify({ 'model': model, 'prompt': text });
1110 break;1109 break;
1111 case TEXTGEN_TYPES.APHRODITE:1110 case TEXTGEN_TYPES.APHRODITE:
1112 url += '/v1/tokenize';1111 url += '/v1/tokenize';
1113 args.body = JSON.stringify({ 'model': aphroditeModel, 'prompt': text });1112 args.body = JSON.stringify({ 'model': model, 'prompt': text });
1114 break;1113 break;
1115 default:1114 default:
1116 url += '/v1/internal/encode';1115 url += '/v1/internal/encode';