Ollama: Add num_batch config value

dd7391caafe13a3b2ddc55ab501450ee6d0d6911

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +9 -0Showing whitespace changes
default/config.yaml+4 -0
@@ -183,6 +183,10 @@ ollama:
183183 # * 0: Unload the model immediately after the request
184184 # * N (any positive number): Keep the model loaded for N seconds after the request.
185185 keepAlive: -1
186+ # Controls the "num_batch" (batch size) parameter of the generation request
187+ # * -1: Use the default value of the model
188+ # * N (positive number): Use the specified value. Must be a power of 2, e.g. 128, 256, 512, etc.
189+ batchSize: -1
186190# -- ANTHROPIC CLAUDE API CONFIGURATION --
187191claude:
188192 # Enables caching of the system prompt (if supported).
src/constants.js+1 -0
@@ -304,6 +304,7 @@ export const TOGETHERAI_KEYS = [
304304export const OLLAMA_KEYS = [
305305 'num_predict',
306306 'num_ctx',
307+ 'num_batch',
307308 'stop',
308309 'temperature',
309310 'repeat_penalty',
src/endpoints/backends/text-completions.js+4 -0
@@ -373,6 +373,10 @@ router.post('/generate', jsonParser, async function (request, response) {
373373
374374 if (request.body.api_type === TEXTGEN_TYPES.OLLAMA) {
375375 const keepAlive = getConfigValue('ollama.keepAlive', -1);
376+ const numBatch = getConfigValue('ollama.batchSize', -1);
377+ if (numBatch > 0) {
378+ request.body['num_batch'] = numBatch;
379+ }
376380 args.body = JSON.stringify({
377381 model: request.body.model,
378382 prompt: request.body.prompt,