build llama.cpp embedding url path by appending instead of overwriting (#5178) * build llama.cpp embedding url path by appending instead of overwriting When using a llama-swap frontend, this allows choosing the embedding model by path; for instance, with the secondary embedding endpoint URL configured to http://127.0.0.1:5001/upstream/emb-model to pick the "emb-model" model. With this approach, the same llama-swap instance can be used to serve both the main LLM and the embedding model from local llama-server commands. * Trim trailing v1 from URL --------- Co-authored-by: Cohee <18619528+Cohee1207@users.noreply.github.com>

ab8d7e518454ad9cc030d8f22c09614246f4695a

Wagner Bruna <wbruna@users.noreply.github.com>

Signed
1 files changed, +3 -2Showing whitespace changes
src/vectors/llamacpp-vectors.js+3 -2
@@ -1,6 +1,8 @@
11import fetch from 'node-fetch';
2+import urlJoin from 'url-join';
23import { setAdditionalHeadersByType } from '../additional-headers.js';
34import { TEXTGEN_TYPES } from '../constants.js';
5+import { trimV1 } from '../util.js';
46
57/**
68 * Gets the vector for the given text from LlamaCpp
@@ -10,8 +12,7 @@ import { TEXTGEN_TYPES } from '../constants.js';
1012 * @returns {Promise<number[][]>} - The array of vectors for the texts
1113 */
1214export async function getLlamaCppBatchVector(texts, apiUrl, directories) {
1315 const url = new URL(urlJoin(trimV1(apiUrl), '/v1/embeddings'));
14- url.pathname = '/v1/embeddings';
1516
1617 const headers = {};
1718 setAdditionalHeadersByType(headers, TEXTGEN_TYPES.LLAMACPP, apiUrl, directories);