{"record":{"id":"0104c868cb305bb3","repo":"SillyTavern/SillyTavern","slug":"llamacpp-failed-to-get-vector-for-text-respons","errorCode":null,"errorMessage":"LlamaCpp: Failed to get vector for text: ${response.statusText} ${responseText}","messagePattern":"LlamaCpp: Failed to get vector for text: (.+?) (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/vectors/llamacpp-vectors.js","lineNumber":31,"sourceCode":" */\nexport async function getLlamaCppBatchVector(texts, apiUrl, directories) {\n    const url = new URL(urlJoin(trimV1(apiUrl), '/v1/embeddings'));\n\n    const headers = {};\n    setAdditionalHeadersByType(headers, TEXTGEN_TYPES.LLAMACPP, apiUrl, directories);\n\n    const response = await fetch(url, {\n        method: 'POST',\n        headers: {\n            'Content-Type': 'application/json',\n            ...headers,\n        },\n        body: JSON.stringify({ input: texts }),\n    });\n\n    if (!response.ok) {\n        const responseText = await response.text();\n        throw new Error(`LlamaCpp: Failed to get vector for text: ${response.statusText} ${responseText}`);\n    }\n\n    /** @type {any} */\n    const data = await response.json();\n\n    if (!Array.isArray(data?.data)) {\n        throw new Error('API response was not an array');\n    }\n\n    // Sort data by x.index to ensure the order is correct\n    data.data.sort((a, b) => a.index - b.index);\n\n    const vectors = data.data.map(x => x.embedding);\n    return vectors;\n}\n\n/**\n * Gets the vector for the given text from LlamaCpp","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/SillyTavern/SillyTavern/blob/8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8/src/vectors/llamacpp-vectors.js#L13-L49","documentation":"The LlamaCpp vectors connector POSTs { input: texts } to a LlamaCpp endpoint and throws a descriptive error including response.statusText and the response text when response.ok is false. LlamaCpp is a self-hosted local inference server, so failure usually means the server rejected the embedding request or is unreachable in a degraded way.","triggerScenarios":"LlamaCpp returns non-2xx: model not loaded, embedding not supported by the loaded model, input too long, server misconfigured, or wrong endpoint path.","commonSituations":"LlamaCpp server started without --embedding support, model that doesn't produce embeddings, context length exceeded by input, wrong API URL, or LlamaCpp version with a different endpoint.","solutions":["Read the embedded statusText and responseText to see LlamaCpp's error message.","Restart LlamaCpp with embedding support enabled for the loaded model.","Use a model that supports embeddings.","Reduce input text length to fit the model's context window.","Confirm the API URL points at the correct LlamaCpp embedding endpoint."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Validate the LlamaCpp URL and inputs before calling\nif (!url) throw new Error('LlamaCpp URL is not configured');\nif (!Array.isArray(texts) || texts.length === 0) throw new Error('texts must be a non-empty array');","typeGuard":null,"tryCatchPattern":"try {\n    return await getLlamaCppBatchVector(texts, ...);\n} catch (e) {\n    if (e.message.startsWith('LlamaCpp: Failed to get vector')) {\n        // inspect embedded statusText/responseText; retry once for transient server errors\n    } else throw e;\n}","preventionTips":["Start LlamaCpp with embedding support for an embedding-capable model.","Keep inputs within the model's context window.","Confirm the API URL points at the embedding endpoint.","Read the embedded statusText/responseText to classify the failure."],"tags":["vectors","llamacpp","network","http","embeddings","self-hosted"],"backgroundTag":null,"analyzedSha":"8172dcd0ee672d3cd9a5e5f7af134f91a45cd2b8","analyzedAt":"2026-08-13T07:48:40.832Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}