feat(grammar): expose properties_order (#2662)

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto 2024-06-26 14:59:02 +02:00 committed by GitHub
parent a8bfb6f9c2
commit 3eaf59021c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 0 deletions

View File

@ -42,3 +42,9 @@ func SetPrefix(suffix string) func(*GrammarOption) {
o.Prefix = suffix
}
}
func SetPropOrder(order string) func(*GrammarOption) {
return func(o *GrammarOption) {
o.PropOrder = order
}
}

View File

@ -32,6 +32,11 @@ type GrammarConfig struct {
// ExpectStringsAfterJSON enables mixed string suffix
ExpectStringsAfterJSON bool `yaml:"expect_strings_after_json"`
// PropOrder selects what order to print properties
// for instance name,arguments will make print { "name": "foo", "arguments": { "bar": "baz" } }
// instead of { "arguments": { "bar": "baz" }, "name": "foo" }
PropOrder string `yaml:"properties_order"`
}
// FunctionsConfig is the configuration for the tool/function call.
@ -104,6 +109,8 @@ func (g GrammarConfig) Options() []func(o *GrammarOption) {
if g.ExpectStringsAfterJSON {
opts = append(opts, ExpectStringsAfterJSON)
}
opts = append(opts, SetPropOrder(g.PropOrder))
return opts
}