@@ -34,6 +34,9 @@ Increases the verbosity of the llama.cpp server.
3434. PARAMETER help
3535Shows the manual on how to use this script.
3636
37+ . PARAMETER additionalArguments
38+ Adds additional arguments to the llama.cpp server that are not handled by this script.
39+
3740. EXAMPLE
3841.\server.ps1 -model "..\vendor\llama.cpp\models\gemma-2-9b-it-IQ4_XS.gguf"
3942
@@ -48,6 +51,9 @@ Shows the manual on how to use this script.
4851
4952. EXAMPLE
5053.\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"
5157#>
5258
5359Param (
@@ -117,7 +123,11 @@ Param (
117123 $kvCacheDataType = " f16" ,
118124
119125 [switch ]
120- $help
126+ $help ,
127+
128+ [Parameter ()]
129+ [String ]
130+ $additionalArguments
121131)
122132
123133if ($help ) {
@@ -302,7 +312,6 @@ Write-Host "Starting llama.cpp server with custom options at http://127.0.0.1:${
302312$commandBinary = " ${llamaCppPath} \build\bin\Release\llama-server"
303313
304314$commandArguments = @ (
305- " --n-predict 1024" ,
306315 " --port '${port} '" ,
307316 " --model '${model} '" ,
308317 " --alias '${alias} '" ,
@@ -326,7 +335,32 @@ if ($verbose) {
326335 $commandArguments += " --verbose"
327336}
328337
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+
329362$commandArguments = $commandArguments | ForEach-Object {
363+
330364 if ($commandArguments.IndexOf ($_ ) -ne $commandArguments.Count - 1 ) {
331365 " $_ ```n "
332366 } else {
0 commit comments