Fix vLLM vector embeddings URL construction to preserve custom API path prefixes (#5350) * Initial plan * fix: use trimV1 and url-join for vLLM vector embeddings URL construction Fixes URL path construction in vllm-vectors.js to preserve custom API path prefixes (e.g. /compatible-mode/v1). Previously url.pathname assignment would overwrite the entire path, stripping any prefix. Now uses the same trimV1 + urlJoin pattern as llamacpp-vectors.js. Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com> Agent-Logs-Url: https://github.com/SillyTavern/SillyTavern/sessions/f708dd66-8961-4c23-8b8b-3ab868bf676a * Revert package-lock --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Cohee1207 <18619528+Cohee1207@users.noreply.github.com>
Signed| @@ -1,6 +1,8 @@ | ||
| 1 | 1 | import fetch from 'node-fetch'; |
| 2 | +import urlJoin from 'url-join'; | |
| 2 | 3 | import { setAdditionalHeadersByType } from '../additional-headers.js'; |
| 3 | 4 | import { TEXTGEN_TYPES } from '../constants.js'; |
| 5 | +import { trimV1 } from '../util.js'; | |
| 4 | 6 | |
| 5 | 7 | /** |
| 6 | 8 | * Gets the vector for the given text from VLLM |
| @@ -11,8 +13,7 @@ import { TEXTGEN_TYPES } from '../constants.js'; | ||
| 11 | 13 | * @returns {Promise<number[][]>} - The array of vectors for the texts |
| 12 | 14 | */ |
| 13 | 15 | export async function getVllmBatchVector(texts, apiUrl, model, directories) { |
| 14 | 16 | const url = new URL(urlJoin(trimV1(apiUrl), '/v1/embeddings')); |
| 15 | - url.pathname = '/v1/embeddings'; | |
| 16 | 17 | |
| 17 | 18 | const headers = {}; |
| 18 | 19 | setAdditionalHeadersByType(headers, TEXTGEN_TYPES.VLLM, apiUrl, directories); |