Skip to content

Commit 46310ea

Browse files
committed
feat(conf): remove surrounding single-quotes in llama.ini params
1 parent 7f7d8a1 commit 46310ea

2 files changed

Lines changed: 31 additions & 16 deletions

File tree

conf/llamacppini.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ func (cfg *Cfg) GenLlamaINI() []byte {
3737
out := bytes.NewBufferString(`
3838
version = 1
3939
`)
40-
4140
// For each model, set two model settings:
4241
// 1. for the OpenAI endpoints
4342
// 2. for the /completion endpoint (prefix with A_ and hide the model)
@@ -61,10 +60,8 @@ model = ` + path)
6160
wroteKey := false
6261

6362
for arg := range strings.FieldsSeq(flags) {
64-
arg = strings.TrimSpace(arg)
65-
if arg != "" {
66-
wroteKey = genParam(out, arg, wroteKey)
67-
}
63+
arg = strings.Trim(arg, "'")
64+
wroteKey = genParam(out, arg, wroteKey)
6865
}
6966

7067
if wroteKey {
@@ -76,7 +73,7 @@ model = ` + path)
7673

7774
// Add the model settings within the llama-swap configuration.
7875
func genParam(out *bytes.Buffer, arg string, wroteKey bool) bool {
79-
if arg[0] != '-' {
76+
if arg == "" || arg[0] != '-' {
8077
out.WriteByte(' ')
8178
out.WriteString(arg)
8279
return false

conf/llamacppini_test.go

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,53 @@ func TestCfg_GenLlamaINI(t *testing.T) {
1616
info *ModelInfo
1717
want string
1818
}{
19-
{"model-with-flags", &ModelInfo{Flags: " -c 0 --n-gpu-layers 99 --no-jinja --context-switch "}, `
19+
{"flags", &ModelInfo{Flags: " -c 0 --n-gpu-layers 99 --no-jinja --context-switch "}, `
2020
version = 1
2121
22-
[model-with-flags]
23-
model = /path/model-with-flags.gguf
22+
[flags]
23+
model = /path/flags.gguf
2424
c = 0
2525
n-gpu-layers = 99
2626
no-jinja = true
2727
context-switch = true
2828
29-
[model-with-flags` + PLUS_A + `]
30-
model = /path/model-with-flags.gguf
29+
[flags` + PLUS_A + `]
30+
model = /path/flags.gguf
3131
jinja = true
3232
chat-template-file = template.jinja
3333
c = 0
3434
n-gpu-layers = 99
3535
no-jinja = true
3636
context-switch = true
3737
`},
38-
{"model-no-flags", &ModelInfo{Flags: ""}, `
38+
{"no-flags", &ModelInfo{Flags: ""}, `
3939
version = 1
4040
41-
[model-no-flags]
42-
model = /path/model-no-flags.gguf
41+
[no-flags]
42+
model = /path/no-flags.gguf
4343
44-
[model-no-flags` + PLUS_A + `]
45-
model = /path/model-no-flags.gguf
44+
[no-flags` + PLUS_A + `]
45+
model = /path/no-flags.gguf
4646
jinja = true
4747
chat-template-file = template.jinja
48+
`},
49+
{"quote", &ModelInfo{Flags: `
50+
--chat-template-kwargs '{"reasoning_effort": "high"}'
51+
-ot "blk\.1.\.ffn_.*=CPU"
52+
`}, `
53+
version = 1
54+
55+
[quote]
56+
model = /path/quote.gguf
57+
chat-template-kwargs = {"reasoning_effort": "high"}
58+
ot = "blk\.1.\.ffn_.*=CPU"
59+
60+
[quote` + PLUS_A + `]
61+
model = /path/quote.gguf
62+
jinja = true
63+
chat-template-file = template.jinja
64+
chat-template-kwargs = {"reasoning_effort": "high"}
65+
ot = "blk\.1.\.ffn_.*=CPU"
4866
`},
4967
}
5068
for _, tt := range tests {

0 commit comments

Comments
 (0)