mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-22 11:35:00 +00:00
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:
parent
5dc6bace49
commit
3f7212c660
4 changed files with 43 additions and 15 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue