feat(functions): better free string matching, allow to expect strings after JSON (#2445)

Allow now any non-character, both as suffix and prefix when mixed grammars are enabled

Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto 2024-05-31 09:36:27 +02:00 committed by GitHub
parent 5dc6bace49
commit 3f7212c660
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 43 additions and 15 deletions

View file

@ -2,11 +2,12 @@ package functions
type GrammarOption struct {
PropOrder string
Suffix string
Prefix string
MaybeArray bool
DisableParallelNewLines bool
MaybeString bool
NoMixedFreeString bool
ExpectStringsAfterJSON bool
}
func (o *GrammarOption) Apply(options ...func(*GrammarOption)) {
@ -31,8 +32,13 @@ var NoMixedFreeString func(*GrammarOption) = func(o *GrammarOption) {
o.NoMixedFreeString = true
}
// ExpectStringsAfterJSON enables mixed string suffix
var ExpectStringsAfterJSON func(*GrammarOption) = func(o *GrammarOption) {
o.ExpectStringsAfterJSON = true
}
func SetPrefix(suffix string) func(*GrammarOption) {
return func(o *GrammarOption) {
o.Suffix = suffix
o.Prefix = suffix
}
}