Skip to content

Commit d2c5d17

Browse files
committed
[Server] Add -additionalArguments option
1 parent a1e9524 commit d2c5d17

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.23.0] - 2024-11-26
8+
9+
### Added
10+
- [Server] Add -additionalArguments option
11+
12+
### Removed
13+
714
## [1.22.0] - 2024-10-14
815

916
### Removed

examples/server.ps1

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ Increases the verbosity of the llama.cpp server.
3434
.PARAMETER help
3535
Shows 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

5359
Param (
@@ -117,7 +123,11 @@ Param (
117123
$kvCacheDataType="f16",
118124

119125
[switch]
120-
$help
126+
$help,
127+
128+
[Parameter()]
129+
[String]
130+
$additionalArguments
121131
)
122132

123133
if ($help) {
@@ -325,7 +335,32 @@ if ($verbose) {
325335
$commandArguments += "--verbose"
326336
}
327337

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+
328362
$commandArguments = $commandArguments | ForEach-Object {
363+
329364
if ($commandArguments.IndexOf($_) -ne $commandArguments.Count - 1) {
330365
" $_ ```n"
331366
} else {

vendor/llama.cpp

0 commit comments

Comments
 (0)