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>
Signed| @@ -954,8 +954,7 @@ function getTextgenAPITokenizationParams(str) { | ||
| 954 | 954 | text: str, |
| 955 | 955 | api_type: textgen_settings.type, |
| 956 | 956 | url: getTextGenServer(), |
| 957 | 957 | vllm_modelmodel: textgen_settings.vllm_modelgetTextGenModel(), |
| 958 | - aphrodite_model: textgen_settings.aphrodite_model, | |
| 959 | 958 | }; |
| 960 | 959 | } |
| 961 | 960 | |
| @@ -1077,8 +1077,7 @@ router.post('/remote/textgenerationwebui/encode', async function (request, respo | ||
| 1077 | 1077 | } |
| 1078 | 1078 | const text = String(request.body.text) || ''; |
| 1079 | 1079 | const baseUrl = String(request.body.url); |
| 1080 | 1080 | const vllmModelmodel = String(request.body.vllm_modelmodel) || ''; |
| 1081 | - const aphroditeModel = String(request.body.aphrodite_model) || ''; | |
| 1082 | 1081 | |
| 1083 | 1082 | try { |
| 1084 | 1083 | const args = { |
| @@ -1102,15 +1101,15 @@ router.post('/remote/textgenerationwebui/encode', async function (request, respo | ||
| 1102 | 1101 | break; |
| 1103 | 1102 | case TEXTGEN_TYPES.LLAMACPP: |
| 1104 | 1103 | url += '/tokenize'; |
| 1105 | 1104 | args.body = JSON.stringify({ 'model': model, 'content': text }); |
| 1106 | 1105 | break; |
| 1107 | 1106 | case TEXTGEN_TYPES.VLLM: |
| 1108 | 1107 | url += '/tokenize'; |
| 1109 | 1108 | args.body = JSON.stringify({ 'model': vllmModelmodel, 'prompt': text }); |
| 1110 | 1109 | break; |
| 1111 | 1110 | case TEXTGEN_TYPES.APHRODITE: |
| 1112 | 1111 | url += '/v1/tokenize'; |
| 1113 | 1112 | args.body = JSON.stringify({ 'model': aphroditeModelmodel, 'prompt': text }); |
| 1114 | 1113 | break; |
| 1115 | 1114 | default: |
| 1116 | 1115 | url += '/v1/internal/encode'; |