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:
183 # * 0: Unload the model immediately after the request183 # * 0: Unload the model immediately after the request
184 # * N (any positive number): Keep the model loaded for N seconds after the request.184 # * N (any positive number): Keep the model loaded for N seconds after the request.
185 keepAlive: -1185 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
186# -- ANTHROPIC CLAUDE API CONFIGURATION --190# -- ANTHROPIC CLAUDE API CONFIGURATION --
187claude:191claude:
188 # Enables caching of the system prompt (if supported).192 # Enables caching of the system prompt (if supported).
src/constants.js+1 -0
@@ -304,6 +304,7 @@ export const TOGETHERAI_KEYS = [
304export const OLLAMA_KEYS = [304export const OLLAMA_KEYS = [
305 'num_predict',305 'num_predict',
306 'num_ctx',306 'num_ctx',
307 'num_batch',
307 'stop',308 'stop',
308 'temperature',309 'temperature',
309 'repeat_penalty',310 'repeat_penalty',
src/endpoints/backends/text-completions.js+4 -0
@@ -373,6 +373,10 @@ router.post('/generate', jsonParser, async function (request, response) {
373373
374 if (request.body.api_type === TEXTGEN_TYPES.OLLAMA) {374 if (request.body.api_type === TEXTGEN_TYPES.OLLAMA) {
375 const keepAlive = getConfigValue('ollama.keepAlive', -1);375 const keepAlive = getConfigValue('ollama.keepAlive', -1);
376 const numBatch = getConfigValue('ollama.batchSize', -1);
377 if (numBatch > 0) {
378 request.body['num_batch'] = numBatch;
379 }
376 args.body = JSON.stringify({380 args.body = JSON.stringify({
377 model: request.body.model,381 model: request.body.model,
378 prompt: request.body.prompt,382 prompt: request.body.prompt,