@@ -34,6 +34,9 @@ Increases the verbosity of the llama.cpp server.
34
34
. PARAMETER help
35
35
Shows the manual on how to use this script.
36
36
37
+ . PARAMETER additionalArguments
38
+ Adds additional arguments to the llama.cpp server that are not handled by this script.
39
+
37
40
. EXAMPLE
38
41
.\server.ps1 -model "..\vendor\llama.cpp\models\gemma-2-9b-it-IQ4_XS.gguf"
39
42
@@ -48,6 +51,9 @@ Shows the manual on how to use this script.
48
51
49
52
. EXAMPLE
50
53
.\server.ps1 -model "..\vendor\llama.cpp\models\gemma-2-9b-it-IQ4_XS.gguf" -verbose
54
+
55
+ . EXAMPLE
56
+ .\server.ps1 -model "..\vendor\llama.cpp\models\gemma-2-9b-it-IQ4_XS.gguf" -additionalArguments "--no-slots"
51
57
#>
52
58
53
59
Param (
@@ -117,7 +123,11 @@ Param (
117
123
$kvCacheDataType = " f16" ,
118
124
119
125
[switch ]
120
- $help
126
+ $help ,
127
+
128
+ [Parameter ()]
129
+ [String ]
130
+ $additionalArguments
121
131
)
122
132
123
133
if ($help ) {
@@ -302,7 +312,6 @@ Write-Host "Starting llama.cpp server with custom options at http://127.0.0.1:${
302
312
$commandBinary = " ${llamaCppPath} \build\bin\Release\llama-server"
303
313
304
314
$commandArguments = @ (
305
- " --n-predict 1024" ,
306
315
" --port '${port} '" ,
307
316
" --model '${model} '" ,
308
317
" --alias '${alias} '" ,
@@ -326,7 +335,32 @@ if ($verbose) {
326
335
$commandArguments += " --verbose"
327
336
}
328
337
338
+ # Include additional arguments if they are provided via the -additionalArguments parameter.
339
+ $additionalArgumentParts = $additionalArguments -split ' \s+'
340
+ $index = 0
341
+ while ($index -lt $additionalArgumentParts.Count ) {
342
+
343
+ $argument = $additionalArgumentParts [$index ]
344
+
345
+ $hasNextArgument = $index + 1 -lt $additionalArgumentParts.Count
346
+ $nextArgumentIsValue = ($additionalArgumentParts [$index + 1 ] -notmatch ' ^-{1,2}' )
347
+
348
+ if ($hasNextArgument -and $nextArgumentIsValue ) {
349
+
350
+ # It's a key-value pair.
351
+ $commandArguments += " $argument $ ( $additionalArgumentParts [$index + 1 ]) "
352
+ $index += 2
353
+
354
+ } else {
355
+
356
+ # It's a standalone flag.
357
+ $commandArguments += " $argument "
358
+ $index += 1
359
+ }
360
+ }
361
+
329
362
$commandArguments = $commandArguments | ForEach-Object {
363
+
330
364
if ($commandArguments.IndexOf ($_ ) -ne $commandArguments.Count - 1 ) {
331
365
" $_ ```n "
332
366
} else {
0 commit comments