perf: customizable embedding chunk size via env var (#5494)

* perf: customizable embedding chunk size via env var

* Update .env.template

---------

Co-authored-by: Archer <545436317@qq.com>
This commit is contained in:
Finley Ge
2025-08-20 18:42:15 +08:00
committed by GitHub
parent f41e3ffc68
commit 37eec3d452
2 changed files with 5 additions and 1 deletions

View File

@@ -24,7 +24,7 @@ export async function getVectorsByText({ model, input, type, headers }: GetVecto
const formatInput = Array.isArray(input) ? input : [input];
// 20 size every request
const chunkSize = 20;
const chunkSize = parseInt(process.env.EMBEDDING_CHUNK_SIZE || '10');
const chunks = [];
for (let i = 0; i < formatInput.length; i += chunkSize) {
chunks.push(formatInput.slice(i, i + chunkSize));