Merge pull request #3475 from SillyTavern/ollama-batch Ollama: Add num_batch config value
Signed| @@ -183,6 +183,10 @@ ollama: | |||
| 183 | # * 0: Unload the model immediately after the request | 183 | # * 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: -1 | 185 | 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 -- |
| 187 | claude: | 191 | claude: |
| 188 | # Enables caching of the system prompt (if supported). | 192 | # Enables caching of the system prompt (if supported). |
| @@ -304,6 +304,7 @@ export const TOGETHERAI_KEYS = [ | |||
| 304 | export const OLLAMA_KEYS = [ | 304 | export 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', |
| @@ -373,6 +373,10 @@ router.post('/generate', jsonParser, async function (request, response) { | |||
| 373 | 373 | ||
| 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, |